------------------------------
-- pgDesigner 1.2.17
--
-- Project    : guoguojie
-- Date       : 04/28/2011 18:49:52.038
-- Description: 
------------------------------

CREATE DATABASE guoguojie
  WITH OWNER = guoguojie
       ENCODING = 'UTF8'
       LC_COLLATE = 'zh_CN.UTF-8'
       LC_CTYPE = 'zh_CN.UTF-8'
       CONNECTION LIMIT = -1;
GRANT CONNECT, TEMPORARY ON DATABASE guoguojie TO public;
GRANT ALL ON DATABASE guoguojie TO guoguojie;
COMMENT ON DATABASE guoguojie IS '果果街数据库';

CREATE LANGUAGE PLPGSQL;

-- Start 表's declaration

-- 以下跟内容管理相关
DROP SEQUENCE IF EXISTS "cms_channel_seq" CASCADE;
CREATE SEQUENCE cms_channel_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER SEQUENCE cms_channel_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE cms_channel_seq
  IS '用来生成cms_channel表的标识符';

DROP TABLE IF EXISTS "cms_channel" CASCADE;
CREATE TABLE cms_channel
(
  identifier character varying(50) NOT NULL, -- 频道标识符
  "name" character varying(500) NOT NULL, -- 频道名
  parent character varying(50) NOT NULL DEFAULT '0'::character varying, -- 父频道标识符：顶级频道值为0，非顶级频道参考identifier字段
  deep integer NOT NULL DEFAULT 0, -- 频道深度：顶级频道值为0、非顶级频道逐级加1
  enabled boolean NOT NULL DEFAULT true, -- 是否可用：true-可用、false-不可用
  gmt_created timestamp with time zone NOT NULL DEFAULT now(), -- 创建时间戳
  gmt_modified timestamp with time zone NOT NULL DEFAULT now(), -- 最后修改时间戳
  mark character varying(50) NOT NULL DEFAULT uuid_generate_v4(), -- 频道号
  CONSTRAINT cms_channel_pk PRIMARY KEY (identifier),
  CONSTRAINT cms_channel_mark UNIQUE (mark)
)
WITH (
  OIDS=FALSE
);
ALTER TABLE cms_channel OWNER TO guoguojie;
COMMENT ON TABLE cms_channel IS '频道表';
COMMENT ON COLUMN cms_channel.identifier IS '频道标识符';
COMMENT ON COLUMN cms_channel."name" IS '频道名';
COMMENT ON COLUMN cms_channel.parent IS '父频道标识符：顶级频道值为0，非顶级频道参考identifier字段';
COMMENT ON COLUMN cms_channel.deep IS '频道深度：顶级频道值为0、非顶级频道逐级加1';
COMMENT ON COLUMN cms_channel.enabled IS '是否可用：true-可用、false-不可用';
COMMENT ON COLUMN cms_channel.gmt_created IS '创建时间戳';
COMMENT ON COLUMN cms_channel.gmt_modified IS '最后修改时间戳';
COMMENT ON COLUMN cms_channel.mark IS '频道号';

DROP SEQUENCE IF EXISTS "cms_content_seq" CASCADE;
CREATE SEQUENCE cms_content_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER SEQUENCE cms_content_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE cms_content_seq
  IS '用来生成cms_content表的标识符';

DROP TABLE IF EXISTS "cms_content" CASCADE;
CREATE TABLE "cms_content" (
"identifier" character varying(50) NOT NULL,
"channel" character varying(50) NOT NULL,
"title" character varying(3000) NOT NULL DEFAULT '',
"description" text NOT NULL DEFAULT '',
"picture" character varying(500) NOT NULL DEFAULT '',
"picture2" character varying(500) NOT NULL DEFAULT '',
"hyperlink" character varying(500) NOT NULL DEFAULT '',
"sort" integer NOT NULL DEFAULT 1,
"order_time" timestamp with time zone,
"status" integer NOT NULL DEFAULT 2,
"enabled" boolean NOT NULL DEFAULT true,
"tbl_name" character varying(50) NOT NULL DEFAULT '',
"tbl_identifier" character varying(50) NOT NULL DEFAULT '',
"nickname" character varying(50) NOT NULL DEFAULT '',
"system_tag" character varying(500) NOT NULL DEFAULT '',
"tag_cover" character varying(50) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "cms_content" ADD CONSTRAINT "cms_content_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "cms_content" IS '内容表';
COMMENT ON COLUMN "cms_content"."identifier" IS '内容标识符';
COMMENT ON COLUMN "cms_content"."channel" IS '所属频道：参考cms_channel表中的identifier字段';
COMMENT ON COLUMN "cms_content"."title" IS '内容标题';
COMMENT ON COLUMN "cms_content"."description" IS '内容描述';
COMMENT ON COLUMN "cms_content"."picture" IS '图片地址';
COMMENT ON COLUMN "cms_content"."picture2" IS '图片地址2';
COMMENT ON COLUMN "cms_content"."hyperlink" IS '超链接';
COMMENT ON COLUMN "cms_content"."sort" IS '内容在这个频道里面的编号，以便于排序';
COMMENT ON COLUMN "cms_content"."order_time" IS '预约时间发布内容';
COMMENT ON COLUMN "cms_content"."status" IS '内容状态：1.已发布 2.未发布 3.预约发布';
COMMENT ON COLUMN "cms_content"."enabled" IS '是否可用：true-可用、false-不可用';
COMMENT ON COLUMN "cms_content"."tbl_name" IS '内容来源：从那个表里推过来的';
COMMENT ON COLUMN "cms_content"."tbl_identifier" IS '内容来源：属于那个表里的哪条内容';
COMMENT ON COLUMN "cms_content"."nickname" IS '内容来源：会员的昵称';
COMMENT ON COLUMN "cms_content"."system_tag" IS '对应的doing表的系统标签';
COMMENT ON COLUMN "cms_content"."tag_cover" IS '对应标签的封面，对应的doing_tag表的identifier';
COMMENT ON COLUMN "cms_content"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "cms_content"."gmt_modified" IS '最后修改时间戳';
-- 以上跟内容管理相关

-- 以下跟后台管理相关
DROP SEQUENCE IF EXISTS "admin_user_seq" CASCADE;
CREATE SEQUENCE admin_user_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER SEQUENCE admin_user_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE admin_user_seq
  IS '用来生成admin_user表的标识符';

DROP TABLE IF EXISTS "admin_user" CASCADE;
CREATE TABLE "admin_user" (
"identifier" character varying(50) NOT NULL,
"username" character varying(50) NOT NULL,
"password" character varying(50) NOT NULL DEFAULT '',
"realname" character varying(50) NOT NULL DEFAULT '',
"description" character varying(500) NOT NULL DEFAULT '',
"enabled" boolean NOT NULL DEFAULT true,
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "admin_user" ADD CONSTRAINT "admin_user_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "admin_user" IS '用户表';
COMMENT ON COLUMN "admin_user"."identifier" IS '用户标识符';
COMMENT ON COLUMN "admin_user"."username" IS '用户名';
COMMENT ON COLUMN "admin_user"."password" IS '密码';
COMMENT ON COLUMN "admin_user"."realname" IS '真实姓名';
COMMENT ON COLUMN "admin_user"."description" IS '描述';
COMMENT ON COLUMN "admin_user"."enabled" IS '是否可用：true-可用、false-不可用';
COMMENT ON COLUMN "admin_user"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "admin_user"."gmt_modified" IS '最后修改时间戳';
CREATE UNIQUE INDEX "admin_user_idx_username" ON "admin_user" USING btree ("username");

DROP SEQUENCE IF EXISTS "admin_role_seq" CASCADE;
CREATE SEQUENCE admin_role_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER SEQUENCE admin_role_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE admin_role_seq
  IS '用来生成admin_role表的标识符';

DROP TABLE IF EXISTS "admin_role" CASCADE;
CREATE TABLE "admin_role" (
"identifier" character varying(50) NOT NULL,
"name" character varying(50) NOT NULL DEFAULT '',
"module" character varying(50) NOT NULL DEFAULT '',
"description" character varying(500) NOT NULL DEFAULT '',
"enabled" boolean NOT NULL DEFAULT true,
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "admin_role" ADD CONSTRAINT "admin_role_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "admin_role" IS '角色表';
COMMENT ON COLUMN "admin_role"."identifier" IS '角色标识符';
COMMENT ON COLUMN "admin_role"."name" IS '角色名';
COMMENT ON COLUMN "admin_role"."module" IS '所属模块';
COMMENT ON COLUMN "admin_role"."description" IS '描述';
COMMENT ON COLUMN "admin_role"."enabled" IS '是否可用：true-可用、false-不可用';
COMMENT ON COLUMN "admin_role"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "admin_role"."gmt_modified" IS '最后修改时间戳';

DROP SEQUENCE IF EXISTS "admin_resource_seq" CASCADE;
CREATE SEQUENCE admin_resource_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER SEQUENCE admin_resource_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE admin_resource_seq
  IS '用来生成admin_resource表的标识符';

DROP TABLE IF EXISTS "admin_resource" CASCADE;
CREATE TABLE "admin_resource" (
"identifier" character varying(50) NOT NULL,
"name" character varying(50) NOT NULL DEFAULT '',
"type" character varying(50) NOT NULL DEFAULT '',
"value" character varying(500) NOT NULL DEFAULT '',
"module" character varying(50) NOT NULL DEFAULT '',
"description" character varying(500) NOT NULL DEFAULT '',
"enabled" boolean NOT NULL DEFAULT true,
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "admin_resource" ADD CONSTRAINT "admin_resource_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "admin_resource" IS '资源表';
COMMENT ON COLUMN "admin_resource"."identifier" IS '资源标识符';
COMMENT ON COLUMN "admin_resource"."name" IS '资源名';
COMMENT ON COLUMN "admin_resource"."type" IS '资源类型';
COMMENT ON COLUMN "admin_resource"."value" IS '值';
COMMENT ON COLUMN "admin_resource"."module" IS '所属模块';
COMMENT ON COLUMN "admin_resource"."description" IS '描述';
COMMENT ON COLUMN "admin_resource"."enabled" IS '是否可用：true-可用、false-不可用';
COMMENT ON COLUMN "admin_resource"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "admin_resource"."gmt_modified" IS '最后修改时间戳';

DROP TABLE IF EXISTS "admin_user_role" CASCADE;
CREATE TABLE "admin_user_role" (
"user" character varying(50) NOT NULL,
"role" character varying(50) NOT NULL,
"enabled" boolean NOT NULL DEFAULT true,
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "admin_user_role" ADD CONSTRAINT "admin_user_role_pk" PRIMARY KEY("user","role");
COMMENT ON TABLE "admin_user_role" IS '用户角色关联表';
COMMENT ON COLUMN "admin_user_role"."user" IS '用户：参照admin_user表中的identifier字段';
COMMENT ON COLUMN "admin_user_role"."role" IS '角色：参照admin_role表中的identifier字段';
COMMENT ON COLUMN "admin_user_role"."enabled" IS '是否可用：true-可用、false-不可用';
COMMENT ON COLUMN "admin_user_role"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "admin_user_role"."gmt_modified" IS '最后修改时间戳';

DROP TABLE IF EXISTS "admin_role_resource" CASCADE;
CREATE TABLE "admin_role_resource" (
"role" character varying(50) NOT NULL,
"resource" character varying(50) NOT NULL,
"enabled" boolean NOT NULL DEFAULT true,
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "admin_role_resource" ADD CONSTRAINT "admin_role_resource_pk" PRIMARY KEY("role","resource");
COMMENT ON TABLE "admin_role_resource" IS '角色资源关联表';
COMMENT ON COLUMN "admin_role_resource"."role" IS '角色：参照admin_role表中的identifier字段';
COMMENT ON COLUMN "admin_role_resource"."resource" IS '资源：参照admin_resource表中的identifier字段';
COMMENT ON COLUMN "admin_role_resource"."enabled" IS '是否可用：true-可用、false-不可用';
COMMENT ON COLUMN "admin_role_resource"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "admin_role_resource"."gmt_modified" IS '最后修改时间戳';
-- 以上跟后台管理相关

-- 以下是辅助系统运行的非业务性质的表
DROP SEQUENCE IF EXISTS "aux_profiler_seq" CASCADE;
CREATE SEQUENCE aux_profiler_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER SEQUENCE aux_profiler_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE aux_profiler_seq
  IS '用来生成aux_profiler表的标识符';

DROP TABLE IF EXISTS "aux_profiler" CASCADE;
CREATE TABLE "aux_profiler" (
"identifier" character varying(50) NOT NULL,
"ip" character varying(50) NOT NULL DEFAULT '',
"user_agent" text NOT NULL DEFAULT '',
"referer" text NOT NULL DEFAULT '',
"url" text NOT NULL DEFAULT '',
"runtime" integer NOT NULL DEFAULT 0,
"total_runtime" bigint NOT NULL DEFAULT 0,
"total_view" integer NOT NULL DEFAULT 0,
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "aux_profiler" ADD CONSTRAINT "aux_profiler_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "aux_profiler" IS '应用分析';
COMMENT ON COLUMN "aux_profiler"."identifier" IS '记录标识符';
COMMENT ON COLUMN "aux_profiler"."ip" IS '最后一次访问的客户端ip';
COMMENT ON COLUMN "aux_profiler"."user_agent" IS '最后一次访问的客户端代理';
COMMENT ON COLUMN "aux_profiler"."referer" IS '最后一次访问的http协议中定义的来源';
COMMENT ON COLUMN "aux_profiler"."url" IS '请求的url';
COMMENT ON COLUMN "aux_profiler"."runtime" IS '最后一次请求执行时间：以毫秒为单位';
COMMENT ON COLUMN "aux_profiler"."total_runtime" IS '总的请求执行时间：以毫秒为单位';
COMMENT ON COLUMN "aux_profiler"."total_view" IS '总的访问次数';
COMMENT ON COLUMN "aux_profiler"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "aux_profiler"."gmt_modified" IS '最后修改时间戳';
CREATE UNIQUE INDEX "aux_profiler_url" ON "aux_profiler" USING btree ("url");

DROP SEQUENCE IF EXISTS "aux_test_seq" CASCADE;
CREATE SEQUENCE aux_test_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER SEQUENCE aux_test_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE aux_test_seq
  IS '用来生成aux_test表的标识符';

DROP TABLE IF EXISTS "aux_test" CASCADE;
CREATE TABLE "aux_test" (
"identifier" character varying(50) NOT NULL,
"msg" character varying(50) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "aux_test" ADD CONSTRAINT "aux_test_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "aux_test" IS '用来测试平台是否正常运行的表';
COMMENT ON COLUMN "aux_test"."identifier" IS '记录标识符';
COMMENT ON COLUMN "aux_test"."msg" IS '测试字段';
COMMENT ON COLUMN "aux_test"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "aux_test"."gmt_modified" IS '最后修改时间戳';

DROP TABLE IF EXISTS "code" CASCADE;
CREATE TABLE "code" (
"type" character varying(50) NOT NULL,
"value" character varying(50) NOT NULL,
"label" character varying(50) NOT NULL,
"sort" integer NOT NULL
)
WITH (
  OIDS=TRUE
);
COMMENT ON TABLE "code" IS '编码表';
COMMENT ON COLUMN "code"."type" IS '编码类型：family_role-家庭角色编码、school_type-学校类型编码、blood-血型编码、constellation-星座编码、profile-体貌编码、album_visibility-相册可见度、blog_visibility-日志可见度、blog_class-日志分类、personality_visibility-个性资料可见度、contact_visibility-联系方式可见度、learning_visibility-学习经历可见度、work_visibility-工作经历可见度';
COMMENT ON COLUMN "code"."value" IS '值';
COMMENT ON COLUMN "code"."label" IS '标签';
COMMENT ON COLUMN "code"."sort" IS '按编码类型组后，在分组内的排序字段';

INSERT INTO code(type,value,label,sort) values('family_role','01','爸爸',1);
INSERT INTO code(type,value,label,sort) values('family_role','02','妈妈',2);
INSERT INTO code(type,value,label,sort) values('family_role','03','儿子',3);
INSERT INTO code(type,value,label,sort) values('family_role','04','女儿',4);
INSERT INTO code(type,value,label,sort) values('family_role','05','宝宝',5);

INSERT INTO code(type,value,label,sort) values('school_type','01','大学',1);
INSERT INTO code(type,value,label,sort) values('school_type','02','高中',2);
INSERT INTO code(type,value,label,sort) values('school_type','03','职技校',3);
INSERT INTO code(type,value,label,sort) values('school_type','04','中学',4);
INSERT INTO code(type,value,label,sort) values('school_type','05','小学',5);

INSERT INTO code(type,value,label,sort) values('blood','01','A',1);
INSERT INTO code(type,value,label,sort) values('blood','02','B',2);
INSERT INTO code(type,value,label,sort) values('blood','03','O',3);
INSERT INTO code(type,value,label,sort) values('blood','04','AB',4);
INSERT INTO code(type,value,label,sort) values('blood','05','其它',5);

INSERT INTO code(type,value,label,sort) values('constellation','01','水瓶座',1);
INSERT INTO code(type,value,label,sort) values('constellation','02','双鱼座',2);
INSERT INTO code(type,value,label,sort) values('constellation','03','白羊座',3);
INSERT INTO code(type,value,label,sort) values('constellation','04','金牛座',4);
INSERT INTO code(type,value,label,sort) values('constellation','05','双子座',5);
INSERT INTO code(type,value,label,sort) values('constellation','06','巨蟹座',6);
INSERT INTO code(type,value,label,sort) values('constellation','07','狮子座',7);
INSERT INTO code(type,value,label,sort) values('constellation','08','处女座',8);
INSERT INTO code(type,value,label,sort) values('constellation','09','天枰座',9);
INSERT INTO code(type,value,label,sort) values('constellation','10','天蝎座',10);
INSERT INTO code(type,value,label,sort) values('constellation','11','射手座',11);
INSERT INTO code(type,value,label,sort) values('constellation','12','魔羯座',12);
INSERT INTO code(type,value,label,sort) values('constellation','13','保密',13);

INSERT INTO code(type,value,label,sort) values('profile','01','苗条',1);
INSERT INTO code(type,value,label,sort) values('profile','02','匀称',2);
INSERT INTO code(type,value,label,sort) values('profile','03','健壮',3);
INSERT INTO code(type,value,label,sort) values('profile','04','高大',4);
INSERT INTO code(type,value,label,sort) values('profile','05','小巧',5);
INSERT INTO code(type,value,label,sort) values('profile','06','丰满',6);
INSERT INTO code(type,value,label,sort) values('profile','07','高挑',7);
INSERT INTO code(type,value,label,sort) values('profile','08','较胖',8);
INSERT INTO code(type,value,label,sort) values('profile','09','较瘦',9);
INSERT INTO code(type,value,label,sort) values('profile','10','运动型',10);
INSERT INTO code(type,value,label,sort) values('profile','11','保密',11);

INSERT INTO code(type,value,label,sort) values('album_visibility','01','全站会员可见',1);
INSERT INTO code(type,value,label,sort) values('album_visibility','02','全好友可见',2);
INSERT INTO code(type,value,label,sort) values('album_visibility','03','仅指定的好友可见',3);
INSERT INTO code(type,value,label,sort) values('album_visibility','04','仅自己可见',4);
INSERT INTO code(type,value,label,sort) values('album_visibility','05','凭密码查看',5);

INSERT INTO code(type,value,label,sort) values('blog_visibility','01','任何人可见',1);
INSERT INTO code(type,value,label,sort) values('blog_visibility','02','所有邻居可见',2);
INSERT INTO code(type,value,label,sort) values('blog_visibility','03','仅自己可见',3);

INSERT INTO code(type,value,label,sort) values('blog_class','01','玩',1);
INSERT INTO code(type,value,label,sort) values('blog_class','02','学',2);
INSERT INTO code(type,value,label,sort) values('blog_class','03','医',3);
INSERT INTO code(type,value,label,sort) values('blog_class','04','用',4);
INSERT INTO code(type,value,label,sort) values('blog_class','05','食',5);
INSERT INTO code(type,value,label,sort) values('blog_class','06','其它',6);

INSERT INTO code(type,value,label,sort) values('personality_visibility','01','全站会员可见',1);
INSERT INTO code(type,value,label,sort) values('personality_visibility','02','仅好友可见',2);

INSERT INTO code(type,value,label,sort) values('contact_visibility','01','全站会员可见',1);
INSERT INTO code(type,value,label,sort) values('contact_visibility','02','仅好友可见',2);

INSERT INTO code(type,value,label,sort) values('learning_visibility','01','全站会员可见',1);
INSERT INTO code(type,value,label,sort) values('learning_visibility','02','仅好友可见',2);

INSERT INTO code(type,value,label,sort) values('work_visibility','01','全站会员可见',1);
INSERT INTO code(type,value,label,sort) values('work_visibility','02','仅好友可见',2);

DROP TABLE IF EXISTS "address_code" CASCADE;
CREATE TABLE "address_code" (
"province" character varying(20) NOT NULL DEFAULT '',
"city" character varying(20) NOT NULL DEFAULT '',
"county" character varying(20) NOT NULL DEFAULT '',
"town" character varying(20) NOT NULL DEFAULT '',
"no5" character varying(20) NOT NULL DEFAULT '',
"no6" character varying(20) NOT NULL DEFAULT '',
"no7" character varying(20) NOT NULL DEFAULT '',
"no8" character varying(20) NOT NULL DEFAULT '',
"value" character varying(50) NOT NULL DEFAULT ''
)
WITH (
  OIDS=TRUE
);
COMMENT ON TABLE "address_code" IS '地址编码表';
COMMENT ON COLUMN "address_code"."province" IS '省份编码值';
COMMENT ON COLUMN "address_code"."city" IS '城市编码值';
COMMENT ON COLUMN "address_code"."county" IS '区或者县编码值';
COMMENT ON COLUMN "address_code"."town" IS '街道或者镇编码值';
COMMENT ON COLUMN "address_code"."no5" IS '保留字段';
COMMENT ON COLUMN "address_code"."no6" IS '保留字段';
COMMENT ON COLUMN "address_code"."no7" IS '保留字段';
COMMENT ON COLUMN "address_code"."no8" IS '保留字段';
COMMENT ON COLUMN "address_code"."value" IS '编码对应的地址';
-- 以上是辅助系统运行的非业务性质的表

-- 以下跟会员相关
DROP SEQUENCE IF EXISTS "member_seq" CASCADE;
CREATE SEQUENCE member_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER SEQUENCE member_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE member_seq
  IS '用来生成member表的标识符';

DROP TABLE IF EXISTS "member" CASCADE;
CREATE TABLE "member" (
"identifier" character varying(50) NOT NULL,
"family" character varying(50) NOT NULL DEFAULT '',
"username" character varying(50) NOT NULL DEFAULT '',
"nickname" character varying(50) NOT NULL DEFAULT '',
"image_server" character varying(500) NOT NULL DEFAULT '',
"avatar" character varying(300) NOT NULL DEFAULT '',
"password" character varying(50) NOT NULL DEFAULT '',
"salt" character varying(10) NOT NULL DEFAULT '',
"email" character varying(100) NOT NULL DEFAULT '',
"mobilephone" character varying(20) NOT NULL DEFAULT '',
"role" char(2) NOT NULL DEFAULT '',
"is_host" boolean NOT NULL DEFAULT false,
"is_active" boolean NOT NULL DEFAULT false,
"is_son" boolean NOT NULL DEFAULT false,
"active_code" character varying(50) NOT NULL DEFAULT '',
"reset_password" character varying(200) NOT NULL DEFAULT '',
"register_ip" character varying(50) NOT NULL DEFAULT '',
"register_time" timestamp with time zone NOT NULL DEFAULT now(),
"login_ip" character varying(50) NOT NULL DEFAULT '',
"login_time" timestamp with time zone NOT NULL DEFAULT now(),
"login_count" integer NOT NULL DEFAULT 1,
"total_online_time" bigint NOT NULL DEFAULT 0,
"enabled" boolean NOT NULL DEFAULT true,
"approve_status" char(2) NOT NULL DEFAULT '01',
"approve_reason" text NOT NULL DEFAULT '',
"approve_date" timestamp with time zone,
"approve_img" character varying(300),
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "member" ADD CONSTRAINT "member_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "member" IS '会员';
COMMENT ON COLUMN "member"."identifier" IS '会员标识符';
COMMENT ON COLUMN "member"."family" IS '属于那一个家庭：参照family表中的doorplate字段';
COMMENT ON COLUMN "member"."username" IS '真实名字';
COMMENT ON COLUMN "member"."nickname" IS '昵称';
COMMENT ON COLUMN "member"."image_server" IS '头像图片的服务器地址';
COMMENT ON COLUMN "member"."avatar" IS '头像图片在图片服务器上的保存路径';
COMMENT ON COLUMN "member"."password" IS '密码';
COMMENT ON COLUMN "member"."salt" IS '密码MD5加密辅助字段';
COMMENT ON COLUMN "member"."email" IS '登录邮箱';
COMMENT ON COLUMN "member"."mobilephone" IS '登录手机号';
COMMENT ON COLUMN "member"."role" IS '家庭角色：参考code表中type字段为family_role的记录';
COMMENT ON COLUMN "member"."is_host" IS '是否是户主：true-是、false-否';
COMMENT ON COLUMN "member"."is_active" IS '是否激活：true-是、false-否';
COMMENT ON COLUMN "member"."is_son" IS '是否超级帐号的小号';
COMMENT ON COLUMN "member"."active_code" IS '激活码';
COMMENT ON COLUMN "member"."reset_password" IS '找回密码时使用该字段';
COMMENT ON COLUMN "member"."register_ip" IS '注册的所在IP';
COMMENT ON COLUMN "member"."register_time" IS '注册的时间';
COMMENT ON COLUMN "member"."login_ip" IS '登录IP';
COMMENT ON COLUMN "member"."login_time" IS '登录时间';
COMMENT ON COLUMN "member"."login_count" IS '登录次数';
COMMENT ON COLUMN "member"."total_online_time" IS '会员从注册起，截至到目前的在线累积时间';
COMMENT ON COLUMN "member"."enabled" IS '是否屏蔽：true-没屏蔽、false-已屏蔽';
COMMENT ON COLUMN "member"."approve_status" IS '认证的状态 01-未提交认证 02-提交审核中 03-通过申请 04-拒绝申请 05-收回认证';
COMMENT ON COLUMN "member"."approve_reason" IS '提交申请认证的理由';
COMMENT ON COLUMN "member"."approve_img" IS '提交申请认证的图片';
COMMENT ON COLUMN "member"."approve_date" IS '提交申请认证的时间';
COMMENT ON COLUMN "member"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "member"."gmt_modified" IS '最后修改时间戳';
CREATE UNIQUE INDEX "member_nickname" ON "member" USING btree ("nickname");

DROP TABLE IF EXISTS "member_detail" CASCADE;
CREATE TABLE "member_detail" (
"member" character varying(50) NOT NULL,
"blood" character varying(50) NOT NULL DEFAULT '',
"constellation" character varying(50) NOT NULL DEFAULT '',
"profile" character varying(50) NOT NULL DEFAULT '',
"introduction" character varying(500) NOT NULL DEFAULT '',
"email" character varying(100) NOT NULL DEFAULT '',
"phone" character varying(20) NOT NULL DEFAULT '',
"mobilephone" character varying(20) NOT NULL DEFAULT '',
"qq" character varying(20) NOT NULL DEFAULT '',
"msn" character varying(20) NOT NULL DEFAULT '',
"province_code" character varying(20) NOT NULL DEFAULT '',
"province" character varying(50) NOT NULL DEFAULT '',
"city_code" character varying(20) NOT NULL DEFAULT '',
"city" character varying(50) NOT NULL DEFAULT '',
"county_code" character varying(20) NOT NULL DEFAULT '',
"county" character varying(50) NOT NULL DEFAULT '',
"town_code" character varying(20) NOT NULL DEFAULT '',
"town" character varying(50) NOT NULL DEFAULT '',
"address" character varying(300) NOT NULL DEFAULT '',
"zipcode" character varying(50) NOT NULL DEFAULT '',
"birth_province_code" character varying(20) NOT NULL DEFAULT '',
"birth_province" character varying(50) NOT NULL DEFAULT '',
"birth_city_code" character varying(20) NOT NULL DEFAULT '',
"birth_city" character varying(50) NOT NULL DEFAULT '',
"birth_county_code" character varying(20) NOT NULL DEFAULT '',
"birth_county" character varying(50) NOT NULL DEFAULT '',
"birth_town_code" character varying(20) NOT NULL DEFAULT '',
"birth_town" character varying(50) NOT NULL DEFAULT '',
"birth_address" character varying(300) NOT NULL DEFAULT '',
"birth_zipcode" character varying(50) NOT NULL DEFAULT '',
"birthday" character varying(50) NOT NULL DEFAULT '',
"sex" char(1) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "member_detail" ADD CONSTRAINT "member_detail_pk" PRIMARY KEY("member");
COMMENT ON TABLE "member_detail" IS '会员详细资料';
COMMENT ON COLUMN "member_detail"."member" IS '属于那一个会员：参照member表中的identifier字段';
COMMENT ON COLUMN "member_detail"."blood" IS '血型：参考code表中type字段为blood的记录';
COMMENT ON COLUMN "member_detail"."constellation" IS '星座：参考code表中type字段为constellation的记录';
COMMENT ON COLUMN "member_detail"."profile" IS '体貌：参考code表中type字段为profile的记录';
COMMENT ON COLUMN "member_detail"."introduction" IS '简介';
COMMENT ON COLUMN "member_detail"."email" IS '邮箱';
COMMENT ON COLUMN "member_detail"."phone" IS '电话';
COMMENT ON COLUMN "member_detail"."mobilephone" IS '手机';
COMMENT ON COLUMN "member_detail"."qq" IS 'qq号';
COMMENT ON COLUMN "member_detail"."msn" IS 'msn号';
COMMENT ON COLUMN "member_detail"."province_code" IS '现居住地的省份编码';
COMMENT ON COLUMN "member_detail"."province" IS '现居住地的省份';
COMMENT ON COLUMN "member_detail"."city_code" IS '现居住地的市编码';
COMMENT ON COLUMN "member_detail"."city" IS '现居住地的市';
COMMENT ON COLUMN "member_detail"."county_code" IS '现居住地的区或者县编码';
COMMENT ON COLUMN "member_detail"."county" IS '现居住地的区或者县';
COMMENT ON COLUMN "member_detail"."town_code" IS '现居住地的街道或者镇编码';
COMMENT ON COLUMN "member_detail"."town" IS '现居住地的街道或者镇';
COMMENT ON COLUMN "member_detail"."address" IS '现居住地的详细地址';
COMMENT ON COLUMN "member_detail"."zipcode" IS '现居住地的邮政编码';
COMMENT ON COLUMN "member_detail"."birth_province_code" IS '出生地的省份编码';
COMMENT ON COLUMN "member_detail"."birth_province" IS '出生地的省份';
COMMENT ON COLUMN "member_detail"."birth_city_code" IS '出生地的市编码';
COMMENT ON COLUMN "member_detail"."birth_city" IS '出生地的市';
COMMENT ON COLUMN "member_detail"."birth_county_code" IS '出生地的区或者县编码';
COMMENT ON COLUMN "member_detail"."birth_county" IS '出生地的区或者县';
COMMENT ON COLUMN "member_detail"."birth_town_code" IS '出生地的街道或者镇编码';
COMMENT ON COLUMN "member_detail"."birth_town" IS '出生地的街道或者镇';
COMMENT ON COLUMN "member_detail"."birth_address" IS '出生地的详细地址';
COMMENT ON COLUMN "member_detail"."birth_zipcode" IS '出生地的邮政编码';
COMMENT ON COLUMN "member_detail"."birthday" IS '生日';
COMMENT ON COLUMN "member_detail"."sex" IS '性别：M-男、F-女';
COMMENT ON COLUMN "member_detail"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "member_detail"."gmt_modified" IS '最后修改时间戳';

DROP SEQUENCE IF EXISTS "member_out_account_seq" CASCADE;
CREATE SEQUENCE member_out_account_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER SEQUENCE member_out_account_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE member_out_account_seq
  IS '用来生成member_out_account表的标识符';

DROP TABLE IF EXISTS "member_out_account" CASCADE;
CREATE TABLE "member_out_account" (
"identifier" character varying(50) NOT NULL,
"member" character varying(50) NOT NULL,
"out_account_id" character varying(50) NOT NULL,
"out_account_type" character varying(20) NOT NULL,
"out_account_name" character varying(50) NOT NULL DEFAULT '',
"access_token" character varying(50) NOT NULL DEFAULT '',
"access_secret" character varying(50) NOT NULL DEFAULT '',
"enabled" boolean NOT NULL DEFAULT false,
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "member_out_account" ADD CONSTRAINT "member_out_account_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "member_out_account" IS '外部账户表';
COMMENT ON COLUMN "member_out_account"."identifier" IS 'member_out_account标识符';
COMMENT ON COLUMN "member_out_account"."member" IS '属于那一个会员：参照member表中的identifier字段';
COMMENT ON COLUMN "member_out_account"."out_account_id" IS '外部账户标示符';
COMMENT ON COLUMN "member_out_account"."out_account_type" IS '外部账户类型：01-新浪,02-腾讯微博,03-腾讯QQ';
COMMENT ON COLUMN "member_out_account"."out_account_name" IS '外部账户昵称';
COMMENT ON COLUMN "member_out_account"."access_token" IS '获得授权的access_token';
COMMENT ON COLUMN "member_out_account"."access_secret" IS '获得授权的access_secret';
COMMENT ON COLUMN "member_out_account"."enabled" IS '是否能分享到外部帐号的平台：true-可以,false-不可以';
COMMENT ON COLUMN "member_out_account"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "member_out_account"."gmt_modified" IS '最后修改时间戳';
CREATE UNIQUE INDEX "member_out_account_unique" ON "member_out_account" USING btree ("out_account_id","out_account_type");

DROP SEQUENCE IF EXISTS "member_personality_seq" CASCADE;
CREATE SEQUENCE member_personality_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER SEQUENCE member_personality_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE member_personality_seq
  IS '用来生成member_personality表的标识符';

DROP TABLE IF EXISTS "member_personality" CASCADE;
CREATE TABLE "member_personality" (
"identifier" character varying(50) NOT NULL,
"member" character varying(50) NOT NULL DEFAULT '',
"name" character varying(50) NOT NULL DEFAULT '',
"value" character varying(500) NOT NULL DEFAULT '',
"visibility" char(2) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "member_personality" ADD CONSTRAINT "member_personality_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "member_personality" IS '会员个性资料';
COMMENT ON COLUMN "member_personality"."identifier" IS '个性资料标识符';
COMMENT ON COLUMN "member_personality"."member" IS '属于那一个会员：参照member表中的identifier字段';
COMMENT ON COLUMN "member_personality"."name" IS '个性名称';
COMMENT ON COLUMN "member_personality"."value" IS '值';
COMMENT ON COLUMN "member_personality"."visibility" IS '可见度：参考code表中type字段为personality_visibility的记录';
COMMENT ON COLUMN "member_personality"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "member_personality"."gmt_modified" IS '最后修改时间戳';

DROP SEQUENCE IF EXISTS "member_contact_seq" CASCADE;
CREATE SEQUENCE member_contact_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER SEQUENCE member_contact_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE member_contact_seq
  IS '用来生成member_contact表的标识符';

DROP TABLE IF EXISTS "member_contact" CASCADE;
CREATE TABLE "member_contact" (
"identifier" character varying(50) NOT NULL,
"member" character varying(50) NOT NULL DEFAULT '',
"name" character varying(50) NOT NULL DEFAULT '',
"value" character varying(500) NOT NULL DEFAULT '',
"visibility" char(2) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "member_contact" ADD CONSTRAINT "member_contact_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "member_contact" IS '会员联系方式';
COMMENT ON COLUMN "member_contact"."identifier" IS '联系方式标识符';
COMMENT ON COLUMN "member_contact"."member" IS '属于那一个会员：参照member表中的identifier字段';
COMMENT ON COLUMN "member_contact"."name" IS '联系方式';
COMMENT ON COLUMN "member_contact"."value" IS '值';
COMMENT ON COLUMN "member_contact"."visibility" IS '可见度：参考code表中type字段为contact_visibility的记录';
COMMENT ON COLUMN "member_contact"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "member_contact"."gmt_modified" IS '最后修改时间戳';

DROP SEQUENCE IF EXISTS "member_learning_seq" CASCADE;
CREATE SEQUENCE member_learning_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER SEQUENCE member_learning_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE member_learning_seq
  IS '用来生成member_learning表的标识符';

DROP TABLE IF EXISTS "member_learning" CASCADE;
CREATE TABLE "member_learning" (
"identifier" character varying(50) NOT NULL,
"member" character varying(50) NOT NULL DEFAULT '',
"school_type" char(2) NOT NULL DEFAULT '',
"school" character varying(50) NOT NULL DEFAULT '',
"college" character varying(50) NOT NULL DEFAULT '',
"class" character varying(50) NOT NULL DEFAULT '',
"entry_date" character varying(50) NOT NULL DEFAULT '',
"visibility" char(2) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "member_learning" ADD CONSTRAINT "member_learning_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "member_learning" IS '会员学习经历';
COMMENT ON COLUMN "member_learning"."identifier" IS '学习经历标识符';
COMMENT ON COLUMN "member_learning"."member" IS '属于那一个会员：参照member表中的identifier字段';
COMMENT ON COLUMN "member_learning"."school_type" IS '学校类型：参考code表中type字段为school_type的记录';
COMMENT ON COLUMN "member_learning"."school" IS '学校名';
COMMENT ON COLUMN "member_learning"."college" IS '院系';
COMMENT ON COLUMN "member_learning"."class" IS '班级';
COMMENT ON COLUMN "member_learning"."entry_date" IS '入学日期';
COMMENT ON COLUMN "member_learning"."visibility" IS '可见度：参考code表中type字段为learning_visibility的记录';
COMMENT ON COLUMN "member_learning"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "member_learning"."gmt_modified" IS '最后修改时间戳';

DROP SEQUENCE IF EXISTS "member_work_seq" CASCADE;
CREATE SEQUENCE member_work_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER SEQUENCE member_work_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE member_work_seq
  IS '用来生成member_work表的标识符';

DROP TABLE IF EXISTS "member_work" CASCADE;
CREATE TABLE "member_work" (
"identifier" character varying(50) NOT NULL,
"member" character varying(50) NOT NULL DEFAULT '',
"unit" character varying(50) NOT NULL DEFAULT '',
"department" character varying(50) NOT NULL DEFAULT '',
"entry_date" character varying(50) NOT NULL DEFAULT '',
"departure_date" character varying(50) NOT NULL DEFAULT '',
"visibility" char(2) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "member_work" ADD CONSTRAINT "member_work_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "member_work" IS '会员工作经历';
COMMENT ON COLUMN "member_work"."identifier" IS '工作经历标识符';
COMMENT ON COLUMN "member_work"."member" IS '属于那一个会员：参照member表中的identifier字段';
COMMENT ON COLUMN "member_work"."unit" IS '工作单位';
COMMENT ON COLUMN "member_work"."department" IS '所在部门';
COMMENT ON COLUMN "member_work"."entry_date" IS '入职日期';
COMMENT ON COLUMN "member_work"."departure_date" IS '离职日期';
COMMENT ON COLUMN "member_work"."visibility" IS '可见度：参考code表中type字段为work_visibility的记录';
COMMENT ON COLUMN "member_work"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "member_work"."gmt_modified" IS '最后修改时间戳';

DROP SEQUENCE IF EXISTS "member_audit_seq" CASCADE;
CREATE SEQUENCE member_audit_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER SEQUENCE member_audit_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE member_audit_seq
  IS '用来生成member_audit表的标识符';

DROP TABLE IF EXISTS "member_audit" CASCADE;
CREATE TABLE "member_audit" (
"identifier" character varying(50) NOT NULL,
"operation" character varying(50) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
COMMENT ON TABLE "member_audit" IS '会员信息审计';
COMMENT ON COLUMN "member_audit"."identifier" IS '记录标识符';
COMMENT ON COLUMN "member_audit"."operation" IS '操作类型：insert-插入新记录、delete-删除记录、update-修改记录';
COMMENT ON COLUMN "member_audit"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "member_audit"."gmt_modified" IS '最后修改时间戳';

CREATE OR REPLACE FUNCTION process_member_audit() RETURNS TRIGGER AS $member_audit$
    BEGIN
		IF (TG_OP = 'INSERT') THEN
			INSERT INTO member_audit SELECT NEW.identifier, 'insert', now(), now();
			RETURN NEW;
        ELSIF (TG_OP = 'DELETE') THEN
            INSERT INTO member_audit SELECT OLD.identifier, 'delete', now(), now();
            RETURN OLD;
        /*
        ELSIF (TG_OP = 'UPDATE') THEN
            INSERT INTO member_audit SELECT NEW.identifier, 'update', now(), now();
            RETURN NEW;
        */
        END IF;
        RETURN NULL;
    END;
$member_audit$ LANGUAGE plpgsql;

CREATE TRIGGER member_audit AFTER INSERT /*OR UPDATE*/ OR DELETE ON member FOR EACH ROW EXECUTE PROCEDURE process_member_audit();
-- 以上跟会员相关
/*
-- 以下跟家相关
DROP TABLE IF EXISTS "family" CASCADE;
CREATE TABLE "family" (
"doorplate" character varying(50) NOT NULL,
"nickname" character varying(50) NOT NULL DEFAULT '',
"image_server" character varying(500) NOT NULL DEFAULT '',
"avatar" character varying(300) NOT NULL DEFAULT '',
"province_code" character varying(20) NOT NULL DEFAULT '',
"province" character varying(50) NOT NULL DEFAULT '',
"city_code" character varying(20) NOT NULL DEFAULT '',
"city" character varying(50) NOT NULL DEFAULT '',
"county_code" character varying(20) NOT NULL DEFAULT '',
"county" character varying(50) NOT NULL DEFAULT '',
"town_code" character varying(20) NOT NULL DEFAULT '',
"town" character varying(50) NOT NULL DEFAULT '',
"address" character varying(300) NOT NULL DEFAULT '',
"zipcode" character varying(50) NOT NULL DEFAULT '',
"introduction" character varying(500) NOT NULL DEFAULT '',
"integral" integer NOT NULL DEFAULT 0,
"days" integer NOT NULL DEFAULT 0,
"last_login_time" timestamp with time zone DEFAULT now(),
"rookie_reward" character varying(50) NOT NULL DEFAULT '000000000000000',
"is_active" boolean NOT NULL DEFAULT true,
"skin" character varying(300) NOT NULL DEFAULT '',
"have_baby" character varying(2) NOT NULL DEFAULT '01',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "family" ADD CONSTRAINT "family_pk" PRIMARY KEY("doorplate");
COMMENT ON TABLE "family" IS '家';
COMMENT ON COLUMN "family"."doorplate" IS '门牌号：参照doorplate表中的value字段';
COMMENT ON COLUMN "family"."image_server" IS '头像图片的服务器地址';
COMMENT ON COLUMN "family"."avatar" IS '头像图片在图片服务器上的保存路径';
COMMENT ON COLUMN "family"."nickname" IS '昵称';
COMMENT ON COLUMN "family"."province_code" IS '家所在的省份编码';
COMMENT ON COLUMN "family"."province" IS '家所在的省份';
COMMENT ON COLUMN "family"."city_code" IS '家所在的市编码';
COMMENT ON COLUMN "family"."city" IS '家所在的市';
COMMENT ON COLUMN "family"."county_code" IS '家所在的区或者县编码';
COMMENT ON COLUMN "family"."county" IS '家所在的区或者县';
COMMENT ON COLUMN "family"."town_code" IS '家所在的街道或者镇编码';
COMMENT ON COLUMN "family"."town" IS '家所在的街道或者镇';
COMMENT ON COLUMN "family"."address" IS '家的详细地址';
COMMENT ON COLUMN "family"."zipcode" IS '家所在地的邮政编码';
COMMENT ON COLUMN "family"."introduction" IS '家的简介';
COMMENT ON COLUMN "family"."integral" IS '积分';
COMMENT ON COLUMN "family"."days" IS '连续登录的天数';
COMMENT ON COLUMN "family"."last_login_time" IS '最后一次的登录时间';
COMMENT ON COLUMN "family"."rookie_reward" IS '新手奖励的标记(000000000000000)15个0分别代表:1.上传头像 2.填写家的资料 3.创建一个微博，分享一个商品 4.成功发表一个帖子  5.创建一个画报并且收藏6个内容 6.我爱社交 7.我有朋友 8.有人喜欢 9.好喜欢呀 10.分享高手 11.图片分享 12.顶帖高手 13.抢沙发啦 14.画报专家 15.爱心家庭';
COMMENT ON COLUMN "family"."is_active" IS '是否激活：true-是、false-否';
COMMENT ON COLUMN "family"."skin" IS '家的皮肤：CSS地址';
COMMENT ON COLUMN "family"."have_baby" IS '家是否有宝宝：01-没有宝宝、02、有宝宝、03、设置没有';
COMMENT ON COLUMN "family"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "family"."gmt_modified" IS '最后修改时间戳';
-- 以上跟家相关
*/

-- 以下跟消息相关
DROP SEQUENCE IF EXISTS "message_seq" CASCADE;
CREATE SEQUENCE message_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER SEQUENCE message_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE message_seq
  IS '用来生成message表的标识符';

DROP TABLE IF EXISTS "message" CASCADE;--需要删除和更改字段
CREATE TABLE "message" (
"identifier" character varying(50) NOT NULL,
"send_member" character varying(50) NOT NULL DEFAULT '',
"receive_member" character varying(50) NOT NULL DEFAULT '',
"title" character varying(50) NOT NULL DEFAULT '',
"type" char(2) NOT NULL DEFAULT '',
"content" character varying(1000) NOT NULL DEFAULT '',
"is_read" boolean NOT NULL DEFAULT false,
"reply_message_id" character varying(50) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "message" ADD CONSTRAINT "message_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "message" IS '消息';
COMMENT ON COLUMN "message"."identifier" IS '消息标识符';
COMMENT ON COLUMN "message"."send_member" IS '发送消息的会员：参照member表中的identifier字段';
COMMENT ON COLUMN "message"."receive_member" IS '信箱接收人所有者,参照member表中的identifier字段';
COMMENT ON COLUMN "message"."title" IS '标题';
COMMENT ON COLUMN "message"."type" IS '消息类型：01-系统消息、02-好友邀请、03-站内消息、04-回复信息';
COMMENT ON COLUMN "message"."content" IS '消息内容';
COMMENT ON COLUMN "message"."is_read" IS '是否已经阅读：true-已阅读、false-未阅读';
COMMENT ON COLUMN "message"."reply_message_id" IS '如果是回复消息，该字段填写被回复的消息标识符';
COMMENT ON COLUMN "message"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "message"."gmt_modified" IS '最后修改时间戳';

--未读消息的数目
DROP TABLE IF EXISTS "message_amount" CASCADE;--需要更改字段
CREATE TABLE "message_amount" (
"member" character varying(50) NOT NULL,
"unreads" int4 DEFAULT 0 NOT NULL,
"type" character varying(20) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "message_amount" ADD CONSTRAINT "message_amount_pk" PRIMARY KEY("member","type");
COMMENT ON TABLE "message_amount" IS '未读消息数量';
COMMENT ON COLUMN "message_amount"."member" IS '会员的标识';
COMMENT ON COLUMN "message_amount"."unreads" IS '未读消息的数目';
COMMENT ON COLUMN "message_amount"."type" IS '消息类型：comment-评论消息、 system-站内信、private-私信';
COMMENT ON COLUMN "message_amount"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "message_amount"."gmt_modified" IS '最后修改时间戳';
-- 以上跟消息相关

-- 以下跟微博相关
DROP SEQUENCE IF EXISTS "doing_seq" CASCADE;
CREATE SEQUENCE doing_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER SEQUENCE doing_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE doing_seq
  IS '用来生成doing表的标识符';

DROP TABLE IF EXISTS "doing" CASCADE;
CREATE TABLE doing
(
  identifier character varying(50) NOT NULL, -- 微博标识符
  member character varying(50) NOT NULL DEFAULT ''::character varying, -- 发布微博的会员：参照member表中的identifier字段
  view_amount integer NOT NULL DEFAULT 0, -- 浏览数
  reply_amount integer NOT NULL DEFAULT 0, -- 回复数
  "content" text NOT NULL DEFAULT ''::text, -- 内容
  post_ip character varying(20) NOT NULL DEFAULT ''::character varying, -- 发布微博的ip
  is_forward boolean NOT NULL DEFAULT false, -- 是否允许好友转播微博：true-允许、false-不允许
  gmt_created timestamp(6) with time zone NOT NULL DEFAULT now(), -- 创建时间戳
  gmt_modified timestamp(6) with time zone NOT NULL DEFAULT now(), -- 最后修改时间戳
  image_server character varying(500) NOT NULL DEFAULT ''::character varying,
  forwards integer NOT NULL DEFAULT 0, -- 被转播的次数
  rootid character varying(50) NOT NULL DEFAULT ''::character varying, -- 转播的原文ID,对应doing的identifier
  toid character varying(50), -- 转播的ID，对应doing的identifier
  tomember character varying(50), -- 转播的会员ID，对应memeber的identifier
  "type" character varying(10) DEFAULT 'weibo'::character varying, -- 类型(weibo:普通广播 ,forward:转播,reply:回应,posts:帖子,love;喜欢,pictorial:画报,picRoot:画报的根)
  video_url character varying(500),
  video_pic character varying(200),
  "owner" character varying(50) DEFAULT ''::character varying, -- 微博的所有者
  owner_type character varying(20) DEFAULT ''::character varying, -- 微博的所有者类型：family-家、community-社区、company-企业、organization-机构
  enabled boolean NOT NULL DEFAULT true,
  tag character varying(200) NOT NULL DEFAULT ''::character varying, -- 微博用户自定义标签
  system_tag character varying(500) NOT NULL DEFAULT ''::character varying, -- 系统根据产品的内容自动添加的标签
  title character varying(200) DEFAULT ''::character varying, -- 主题的标题
  is_marrow boolean DEFAULT false, -- 是否精华：true-是、false-否
  is_lock boolean DEFAULT false, -- 是否加锁：true-是、false-否
  is_top boolean DEFAULT false, -- 是否置顶：true-是、false-否
  is_recomend boolean DEFAULT false, -- 是否推荐：true-是、false-否
  "class" character varying(50), -- 主题的分类：主题分类可以自己创建
  is_down boolean DEFAULT false, -- 是否下沉
  style character varying(500) DEFAULT ''::character varying, -- 标题的样式
  forumid character varying(50) DEFAULT ''::character varying, -- 帖吧号
  pictorial character varying(50) DEFAULT ''::character varying, -- 属于哪个画报 doing_pictorial的identifier
  gmt_reply timestamp(6) with time zone DEFAULT now(), -- 帖子回复时间
  love_amount integer NOT NULL DEFAULT 0,
  share_type character varying(50) NOT NULL DEFAULT 'text'::character varying, -- 分享类型：product/picture/text
  CONSTRAINT doing_pk PRIMARY KEY (identifier)
)
WITH (
  OIDS=FALSE
);
ALTER TABLE doing OWNER TO guoguojie;
COMMENT ON TABLE doing IS '微博';
COMMENT ON COLUMN doing.identifier IS '微博标识符';
COMMENT ON COLUMN doing.member IS '发布微博的会员：参照member表中的identifier字段';
COMMENT ON COLUMN doing.view_amount IS '浏览数';
COMMENT ON COLUMN doing.reply_amount IS '回复数';
COMMENT ON COLUMN doing."content" IS '内容';
COMMENT ON COLUMN doing.post_ip IS '发布微博的ip';
COMMENT ON COLUMN doing.is_forward IS '是否允许好友转播微博：true-允许、false-不允许';
COMMENT ON COLUMN doing.gmt_created IS '创建时间戳';
COMMENT ON COLUMN doing.gmt_modified IS '最后修改时间戳';
COMMENT ON COLUMN doing.forwards IS '被转播的次数';
COMMENT ON COLUMN doing.rootid IS '转播的原文ID,对应doing的identifier';
COMMENT ON COLUMN doing.toid IS '转播的ID，对应doing的identifier';
COMMENT ON COLUMN doing.tomember IS '转播的会员ID，对应memeber的identifier';
COMMENT ON COLUMN doing."type" IS '类型(weibo:普通广播 ,forward:转播,reply:回应,posts:帖子,love;喜欢,pictorial:画报,picRoot:画报的根)';
COMMENT ON COLUMN doing."owner" IS '微博的所有者';
COMMENT ON COLUMN doing.owner_type IS '微博的所有者类型：family-家、community-社区、company-企业、organization-机构';
COMMENT ON COLUMN doing.tag IS '微博用户自定义标签';
COMMENT ON COLUMN doing.system_tag IS '系统根据产品的内容自动添加的标签';
COMMENT ON COLUMN doing.title IS '主题的标题';
COMMENT ON COLUMN doing.is_marrow IS '是否精华：true-是、false-否';
COMMENT ON COLUMN doing.is_lock IS '是否加锁：true-是、false-否';
COMMENT ON COLUMN doing.is_top IS '是否置顶：true-是、false-否';
COMMENT ON COLUMN doing.is_recomend IS '是否推荐：true-是、false-否';
COMMENT ON COLUMN doing."class" IS '主题的分类：主题分类可以自己创建';
COMMENT ON COLUMN doing.is_down IS '是否下沉';
COMMENT ON COLUMN doing.style IS '标题的样式';
COMMENT ON COLUMN doing.forumid IS '帖吧号';
COMMENT ON COLUMN doing.pictorial IS '属于哪个画报 doing_pictorial的identifier';
COMMENT ON COLUMN doing.gmt_reply IS '帖子回复时间';
COMMENT ON COLUMN doing.share_type IS '分享类型：product/picture/text';

-- 以下跟定时发送微博相关
DROP SEQUENCE IF EXISTS "doing_sync_seq" CASCADE;
CREATE SEQUENCE doing_sync_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER SEQUENCE doing_sync_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE doing_sync_seq
  IS '用来生成doing_sync表的标识符';

DROP TABLE IF EXISTS "doing_sync" CASCADE;
CREATE TABLE "doing_sync" (
"identifier" character varying(50) NOT NULL DEFAULT nextval('doing_sync_seq'),
"picture_url" character varying(500) NOT NULL DEFAULT '',
"content" text NOT NULL DEFAULT '',
"post_ip" character varying(20) NOT NULL DEFAULT '',
"status" character varying(10) NOT NULL DEFAULT 'ready',
"post_time" character varying(50) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "doing_sync" ADD CONSTRAINT "doing_sync_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "doing_sync" IS '定时微博';
COMMENT ON COLUMN "doing_sync"."identifier" IS '定时微博标识符';
COMMENT ON COLUMN "doing_sync"."picture_url" IS '图片地址';
COMMENT ON COLUMN "doing_sync"."content" IS '内容';
COMMENT ON COLUMN "doing_sync"."post_ip" IS '发布定时微博的ip';
COMMENT ON COLUMN "doing_sync"."status" IS '定时微博是否发送：ready-准备发送、ok-已经发送';
COMMENT ON COLUMN "doing_sync"."post_time" IS '定时微博发布时间';
COMMENT ON COLUMN "doing_sync"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "doing_sync"."gmt_modified" IS '最后修改时间戳';
-- 以上跟定时发送微博相关

-- 以下跟微博标签相关
DROP SEQUENCE IF EXISTS "doing_tag_show_seq" CASCADE;
CREATE SEQUENCE doing_tag_show_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER SEQUENCE doing_tag_show_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE doing_tag_show_seq
  IS '用来生成doing_tag_show表的标识符';

DROP TABLE IF EXISTS "doing_tag_show" CASCADE;
CREATE TABLE doing_tag_show
(
identifier character varying(50) NOT NULL,
parent_identifier character varying(50) NOT NULL DEFAULT 0,
name character varying(200) NOT NULL DEFAULT ''::character varying,
deep integer NOT NULL DEFAULT 1,
style character varying(500) NOT NULL DEFAULT ''::character varying,
type integer NOT NULL DEFAULT 1,
gmt_created timestamp with time zone NOT NULL DEFAULT now(),
gmt_modified timestamp with time zone NOT NULL DEFAULT now(),
back_tag character varying(50) DEFAULT ''::character varying,
keywords character varying(3000),
CONSTRAINT doing_tag_show_pk PRIMARY KEY (identifier )
)
WITH (
  OIDS=FALSE
);
ALTER TABLE doing_tag_show
  OWNER TO guoguojie;
COMMENT ON TABLE doing_tag_show IS '前台标签';
COMMENT ON COLUMN doing_tag_show.identifier IS '前台标签标识符';
COMMENT ON COLUMN doing_tag_show.parent_identifier IS '前台标签的父标识符(根目录的父标识符为0)';
COMMENT ON COLUMN doing_tag_show.name IS '前台标签的名称';
COMMENT ON COLUMN doing_tag_show.deep IS '前台标签的分类级别';
COMMENT ON COLUMN doing_tag_show.gmt_created IS '创建时间戳';
COMMENT ON COLUMN doing_tag_show.gmt_modified IS '最后修改时间戳';
COMMENT ON COLUMN doing_tag_show.back_tag IS '引用后台标签的ID，参照doing_tag的identifier字段';
COMMENT ON COLUMN doing_tag_show.keywords IS '关键词，用空格隔开';

/*
DROP SEQUENCE IF EXISTS "doing_tag_seq" CASCADE;
CREATE SEQUENCE doing_tag_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER SEQUENCE doing_tag_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE doing_tag_seq
  IS '用来生成doing_tag表的标识符';

DROP TABLE IF EXISTS "doing_tag" CASCADE;
CREATE TABLE "doing_tag" (
"identifier" character varying(50) NOT NULL,
"parent_identifier" character varying(50) NOT NULL DEFAULT '0',
"name" character varying(200) NOT NULL DEFAULT '',
"deep" integer NOT NULL DEFAULT 1,
"enabled" boolean NOT NULL DEFAULT true,
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "doing_tag" ADD CONSTRAINT "doing_tag_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "doing_tag" IS '微博标签';
COMMENT ON COLUMN "doing_tag"."identifier" IS '微博标签标识符';
COMMENT ON COLUMN "doing_tag"."parent_identifier" IS '该微博标签的父标识符(根目录的父标识符为0)';
COMMENT ON COLUMN "doing_tag"."name" IS '微博标签的名称';
COMMENT ON COLUMN "doing_tag"."deep" IS '微博标签的分类级别';
COMMENT ON COLUMN "doing_tag"."enabled" IS '微博标签是否可用';
COMMENT ON COLUMN "doing_tag"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "doing_tag"."gmt_modified" IS '最后修改时间戳';
*/

DROP SEQUENCE IF EXISTS "doing_product_seq" CASCADE;
CREATE SEQUENCE doing_product_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER TABLE doing_product_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE doing_product_seq
  IS '用来生成doing_product表的标识符';

DROP TABLE IF EXISTS "doing_product" CASCADE;
CREATE TABLE doing_product
(
  identifier character varying(50) NOT NULL, -- 微博商品标识符
  doing character varying(50) NOT NULL DEFAULT ''::character varying, -- 属于哪条微博，对应doing表的identifier
  "name" character varying(500) NOT NULL DEFAULT ''::character varying, -- 微博商品的名字
  pic_url character varying(500) NOT NULL DEFAULT ''::character varying, -- 微博商品的地址
  price numeric(12,2) NOT NULL DEFAULT 0, -- 微博商品的价格
  link_url character varying(500) NOT NULL DEFAULT ''::character varying, -- 微博商品的原链接地址
  "from" character varying(100) NOT NULL DEFAULT ''::character varying, -- 微博商品的来源：淘宝、京东、凡客、拍拍、当当
  gmt_created timestamp with time zone NOT NULL DEFAULT now(), -- 创建时间戳
  gmt_modified timestamp with time zone NOT NULL DEFAULT now(), -- 最后修改时间戳
  member character varying(50) DEFAULT ''::character varying,
  "family" character varying(50) DEFAULT ''::character varying,
  image_server character varying(500),
  pic_thumb character varying(500),
  height_200_xxx integer,
  width_200_xxx integer,
  max_price numeric(12,2) NOT NULL DEFAULT 0, -- 商品最高价
  status character varying(50) NOT NULL DEFAULT ''::character varying, -- 商品状态：onsale/nosale
  original_id character varying(50) NOT NULL DEFAULT ''::character varying, -- 商品的原始ID
  subscribe character varying(10) NOT NULL DEFAULT 'no'::character varying, -- 是否订阅过淘宝的商品变更通知：yes/no
  commission numeric(12,2) NOT NULL DEFAULT 0, -- 佣金
  seller_nick character varying(50) NOT NULL DEFAULT ''::character varying, -- 卖家昵称
  guoguojie_commission_rate numeric(12,2) NOT NULL DEFAULT 1::numeric, -- 果果街返利比例
  view_amount integer NOT NULL DEFAULT 0, -- 浏览数
  CONSTRAINT doing_product_pk PRIMARY KEY (identifier),
  CONSTRAINT doing_product_original UNIQUE (original_id, "from")
)
WITH (
  OIDS=FALSE
"view_amount" Integer NOT NULL DEFAULT 0,
);
ALTER TABLE doing_product OWNER TO guoguojie;
COMMENT ON TABLE doing_product IS '微博商品';
COMMENT ON COLUMN doing_product.identifier IS '微博商品标识符';
COMMENT ON COLUMN doing_product.doing IS '属于哪条微博，对应doing表的identifier';
COMMENT ON COLUMN doing_product."name" IS '微博商品的名字';
COMMENT ON COLUMN doing_product.pic_url IS '微博商品的地址';
COMMENT ON COLUMN doing_product.price IS '微博商品的价格';
COMMENT ON COLUMN doing_product.link_url IS '微博商品的原链接地址';
COMMENT ON COLUMN doing_product."from" IS '微博商品的来源：淘宝、京东、凡客、拍拍、当当';
COMMENT ON COLUMN doing_product.gmt_created IS '创建时间戳';
COMMENT ON COLUMN doing_product.gmt_modified IS '最后修改时间戳';
COMMENT ON COLUMN doing_product.max_price IS '商品最高价';
COMMENT ON COLUMN doing_product.status IS '商品状态：onsale/nosale';
COMMENT ON COLUMN doing_product.original_id IS '商品的原始ID';
COMMENT ON COLUMN doing_product.subscribe IS '是否订阅过淘宝的商品变更通知：yes/no';
COMMENT ON COLUMN doing_product.commission IS '佣金';
COMMENT ON COLUMN doing_product.seller_nick IS '卖家昵称';
COMMENT ON COLUMN doing_product.guoguojie_commission_rate IS '果果返利比例';
COMMENT ON COLUMN doing_product.view_amount IS '浏览数';
CREATE UNIQUE INDEX "doing_product_original_id_from" ON "doing_product" USING btree ("original_id","from");


DROP SEQUENCE IF EXISTS "doing_product_time_seq" CASCADE;
CREATE SEQUENCE doing_product_time_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER TABLE doing_product_time_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE doing_product_time_seq
  IS '用来生成doing_product_time表的标识符';
  
DROP TABLE IF EXISTS "doing_product_time" CASCADE;
CREATE TABLE "doing_product_time" (
"identifier" character varying(50) NOT NULL,
"doing_product_id" character varying(50) NOT NULL DEFAULT '',
"guoguojie_commission_rate" numeric(12,2) NOT NULL DEFAULT 1,
"commission_rate" numeric(12,2) NOT NULL DEFAULT 1,
"enabled" boolean NOT NULL DEFAULT true,
"begin_time" timestamp with time zone NOT NULL DEFAULT now(),
"end_time" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "doing_product_time" ADD CONSTRAINT "doing_product_time_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "doing_product_time" IS '商品限时返利记录';
COMMENT ON COLUMN "doing_product_time"."identifier" IS '标识符';
COMMENT ON COLUMN "doing_product_time"."doing_product_id" IS '商品标识符：参考doing_product表中的identifier字段'; 
COMMENT ON COLUMN "doing_product_time"."guoguojie_commission_rate" IS '果果街返利比率';
COMMENT ON COLUMN "doing_product_time"."commission_rate" IS '电商返利比率';
COMMENT ON COLUMN "doing_product_time"."enabled" IS '是否生效';
COMMENT ON COLUMN "doing_product_time"."begin_time" IS '活动开始时间';
COMMENT ON COLUMN "doing_product_time"."end_time" IS '活动结束时间';
COMMENT ON COLUMN "doing_product_time"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "doing_product_time"."gmt_modified" IS '最后修改时间戳';

DROP SEQUENCE IF EXISTS "doing_picture_seq" CASCADE;
CREATE SEQUENCE doing_picture_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER TABLE doing_picture_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE doing_picture_seq
  IS '用来生成doing_picture表的标识符';

DROP TABLE IF EXISTS "doing_picture" CASCADE;
CREATE TABLE "doing_picture" (
"identifier" character varying(50) NOT NULL,
"doing" character varying(50) NOT NULL DEFAULT '',
"member" character varying(50) NOT NULL DEFAULT '',
"family" character varying(50) NOT NULL DEFAULT '',
"pic_url" character varying(500) NOT NULL DEFAULT '',
"picture_thumbnail"  character varying(500) NOT NULL DEFAULT '',
"image_server" character varying(500) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "doing_picture" ADD CONSTRAINT "doing_picture_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "doing_picture" IS '微博图片';
COMMENT ON COLUMN "doing_picture"."identifier" IS '微博图片标识符';
COMMENT ON COLUMN "doing_picture"."doing" IS '属于哪条微博，对应doing表的identifier';
COMMENT ON COLUMN "doing_picture"."member" IS '发表微博的人';
COMMENT ON COLUMN "doing_picture"."family" IS '发布微博的家庭';
COMMENT ON COLUMN "doing_picture"."pic_url" IS '图片的地址';
COMMENT ON COLUMN "doing_picture"."picture_thumbnail" IS '缩略图的地址';
COMMENT ON COLUMN "doing_picture"."image_server" IS '图片的服务器';
COMMENT ON COLUMN "doing_picture"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "doing_picture"."gmt_modified" IS '最后修改时间戳';

--画报
DROP SEQUENCE IF EXISTS "doing_pictorial_seq" CASCADE;
CREATE SEQUENCE doing_pictorial_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER TABLE doing_pictorial_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE doing_pictorial_seq
  IS '用来生成doing_pictorial表的标识符';

DROP TABLE IF EXISTS "doing_pictorial" CASCADE;
CREATE TABLE "doing_pictorial" (
"identifier" character varying(50) NOT NULL,
"title" character varying(50) NOT NULL DEFAULT '',
"short_title" character varying(20) NOT NULL DEFAULT '',
"cover" character varying(500),
"type" character varying(50) NOT NULL DEFAULT '',
"description" character varying(500) NOT NULL DEFAULT '',
"member" character varying(50) NOT NULL DEFAULT '',
"family"  character varying(50) NOT NULL DEFAULT '',
"view_amount" integer NOT NULL DEFAULT 0,
"comment_amount" integer NOT NULL DEFAULT 0,
"post_ip" character varying(20) NOT NULL DEFAULT '01',
"pic_amount" integer NOT NULL DEFAULT 0,
"pro_amount" integer NOT NULL DEFAULT 0,
"display" character varying(2) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "doing_pictorial" ADD CONSTRAINT "doing_pictorial_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "doing_pictorial" IS '专辑';
COMMENT ON COLUMN "doing_pictorial"."identifier" IS '专辑标识';
COMMENT ON COLUMN "doing_pictorial"."title" IS '专辑的标题';
COMMENT ON COLUMN "doing_pictorial"."short_title" IS '专辑的短标题';
COMMENT ON COLUMN "doing_pictorial"."cover" IS '专辑的封面图片';
COMMENT ON COLUMN "doing_pictorial"."type" IS '专辑的类型 01、晒货 02、街拍 03、萌物 04、美食 05、生活 06、其它';
COMMENT ON COLUMN "doing_pictorial"."member" IS '创建专辑的人';
COMMENT ON COLUMN "doing_pictorial"."family" IS '创建专辑的家庭';
COMMENT ON COLUMN "doing_pictorial"."view_amount" IS '围观数';
COMMENT ON COLUMN "doing_pictorial"."comment_amount" IS '评论数';
COMMENT ON COLUMN "doing_pictorial"."post_ip" IS 'IP';
COMMENT ON COLUMN "doing_pictorial"."pro_amount" IS '本画报的图片总量';
COMMENT ON COLUMN "doing_pictorial"."pro_amount" IS '本画报的商品总量';
COMMENT ON COLUMN "doing_pictorial"."display" IS '前台是否显示 01-显示 02显示';
COMMENT ON COLUMN "doing_pictorial"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "doing_pictorial"."gmt_modified" IS '最后修改时间戳';

--访问画报记录

DROP TABLE IF EXISTS "doing_pictorial_visit" CASCADE;
CREATE TABLE "doing_pictorial_visit" (
"family" character varying(50) NOT NULL DEFAULT '',
"member" character varying(50) NOT NULL DEFAULT '',
"pictorial_id" character varying(50) NOT NULL,
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "doing_pictorial_visit" ADD CONSTRAINT "doing_pictorial_visit_pk" PRIMARY KEY("member","pictorial_id");
COMMENT ON TABLE "doing_pictorial_visit" IS '访问画报记录表';
COMMENT ON COLUMN "doing_pictorial_visit"."family" IS '访问画报记录-对应family表的doorplate';
COMMENT ON COLUMN "doing_pictorial_visit"."member" IS '访问画报记录-对应member表的identifier';
COMMENT ON COLUMN "doing_pictorial_visit"."pictorial_id" IS '对应doing_pictorial表的identifier';
COMMENT ON COLUMN "doing_pictorial_visit"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "doing_pictorial_visit"."gmt_modified" IS '最后修改时间戳';

DROP SEQUENCE IF EXISTS "doing_topic_seq" CASCADE;
CREATE SEQUENCE doing_topic_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER TABLE doing_topic_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE doing_topic_seq
  IS '用来生成doing_topic表的标识符';

DROP TABLE IF EXISTS "doing_topic" CASCADE;
CREATE TABLE "doing_topic" (
"identifier" character varying(50) NOT NULL,
"member" character varying(50) NOT NULL DEFAULT '',
"topic_name" character varying(200) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "doing_topic" ADD CONSTRAINT "doing_topic_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "doing_topic" IS '微博话题';
COMMENT ON COLUMN "doing_topic"."identifier" IS '话题标识符';
COMMENT ON COLUMN "doing_topic"."member" IS '发布话题的会员：参照member表中的identifier字段';
COMMENT ON COLUMN "doing_topic"."topic_name" IS '话题的名字';
COMMENT ON COLUMN "doing_topic"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "doing_topic"."gmt_modified" IS '最后修改时间戳';

DROP SEQUENCE IF EXISTS "doing_topic_relation_seq" CASCADE;
CREATE SEQUENCE doing_topic_relation_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER TABLE doing_topic_relation_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE doing_topic_relation_seq
  IS '用来生成doing_topic_relation表的标识符';

DROP TABLE IF EXISTS "doing_topic_relation" CASCADE;
CREATE TABLE "doing_topic_relation" (
"identifier" character varying(50) NOT NULL,
"topic" character varying(50) NOT NULL DEFAULT '',
"doing" character varying(50) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "doing_topic_relation" ADD CONSTRAINT "doing_topic_relation_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "doing_topic_relation" IS '微博话题关联';
COMMENT ON COLUMN "doing_topic_relation"."identifier" IS '话题关联标识符';
COMMENT ON COLUMN "doing_topic_relation"."topic" IS '话题的标示符：参照doing_topic表中的identifier字段';
COMMENT ON COLUMN "doing_topic_relation"."doing" IS '话题的标示符：参照doing表中的identifier字段';
COMMENT ON COLUMN "doing_topic_relation"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "doing_topic_relation"."gmt_modified" IS '最后修改时间戳';


--微博关注
DROP TABLE IF EXISTS "doing_follow" CASCADE;
CREATE TABLE "doing_follow" (
"follow" character varying(50) NOT NULL,
"member" character varying(50) NOT NULL,
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "doing_follow" ADD CONSTRAINT "doing_follow_pk" PRIMARY KEY("member","follow");
COMMENT ON TABLE "doing_follow" IS '微博关注表';
COMMENT ON COLUMN "doing_follow"."member" IS '关注别人的会员：参照member表中的identifier字段';
COMMENT ON COLUMN "doing_follow"."follow" IS '被关注的会员：参照member表中的identifier字段';
COMMENT ON COLUMN "doing_follow"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "doing_follow"."gmt_modified" IS '最后修改时间戳';


DROP SEQUENCE IF EXISTS "doing_class_seq" CASCADE;
CREATE SEQUENCE doing_class_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER TABLE doing_class_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE doing_class_seq
  IS '用来生成doing_class表的标识符';

DROP TABLE IF EXISTS "doing_class" CASCADE;
CREATE TABLE "doing_class" (
"identifier" varchar(50) NOT NULL,
"owner" varchar(50) DEFAULT ''::character varying NOT NULL,
"owner_type" varchar(20) DEFAULT ''::character varying NOT NULL,
"name" varchar(50) DEFAULT ''::character varying NOT NULL,
"classify" varchar(2) DEFAULT ''::character varying NOT NULL,
"remark" varchar(200) DEFAULT ''::character varying NOT NULL,
"gmt_created" timestamptz(6) DEFAULT now() NOT NULL,
"gmt_modified" timestamptz(6) DEFAULT now() NOT NULL
);
ALTER TABLE "doing_class" ADD CONSTRAINT "doing_class_pk" PRIMARY KEY("identifier");
COMMENT ON COLUMN "doing_class"."identifier" IS '话题分组标识符';
COMMENT ON COLUMN "doing_class"."owner" IS '话题所有者';
COMMENT ON COLUMN "doing_class"."owner_type" IS '话题所有者类型：crowd-群、family-家、community-社区、organization-企业/机构';
COMMENT ON COLUMN "doing_class"."name" IS '话题分组名字';
COMMENT ON COLUMN "doing_class"."classify" IS '该分组的分类';
COMMENT ON COLUMN "doing_class"."remark" IS '备注';
COMMENT ON COLUMN "doing_class"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "doing_class"."gmt_modified" IS '最后修改时间戳';

DROP SEQUENCE IF EXISTS "doing_audit_seq" CASCADE;
CREATE SEQUENCE doing_audit_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER TABLE doing_audit_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE doing_audit_seq
  IS '用来生成doing_audit表的标识符';

DROP TABLE IF EXISTS "doing_audit" CASCADE;
CREATE TABLE "doing_audit" (
"identifier" character varying(50) NOT NULL,
"operation" character varying(50) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
COMMENT ON TABLE "doing_audit" IS '微博信息审计';
COMMENT ON COLUMN "doing_audit"."identifier" IS '记录标识符';
COMMENT ON COLUMN "doing_audit"."operation" IS '操作类型：insert-插入新记录、delete-删除记录、update-修改记录';
COMMENT ON COLUMN "doing_audit"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "doing_audit"."gmt_modified" IS '最后修改时间戳';

CREATE OR REPLACE FUNCTION process_doing_audit() RETURNS TRIGGER AS $doing_audit$
    BEGIN
		IF (TG_OP = 'INSERT') THEN
			INSERT INTO doing_audit SELECT NEW.identifier, 'insert', now(), now();
			RETURN NEW;
        ELSIF (TG_OP = 'DELETE') THEN
            INSERT INTO doing_audit SELECT OLD.identifier, 'delete', now(), now();
            RETURN OLD;
        END IF;
        RETURN NULL;
    END;
$doing_audit$ LANGUAGE plpgsql;

CREATE TRIGGER doing_audit AFTER INSERT OR DELETE ON doing FOR EACH ROW EXECUTE PROCEDURE process_doing_audit();

DROP SEQUENCE IF EXISTS "doing_product_audit_seq" CASCADE;
CREATE SEQUENCE doing_product_audit_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER TABLE doing_product_audit_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE doing_product_audit_seq
  IS '用来生成doing_product_audit表的标识符';

DROP TABLE IF EXISTS "doing_product_audit" CASCADE;
CREATE TABLE "doing_product_audit" (
"identifier" character varying(50) NOT NULL,
"operation" character varying(50) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
COMMENT ON TABLE "doing_product_audit" IS '微博产品信息审计';
COMMENT ON COLUMN "doing_product_audit"."identifier" IS '记录标识符';
COMMENT ON COLUMN "doing_product_audit"."operation" IS '操作类型：insert-插入新记录、delete-删除记录、update-修改记录';
COMMENT ON COLUMN "doing_product_audit"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "doing_product_audit"."gmt_modified" IS '最后修改时间戳';

CREATE OR REPLACE FUNCTION process_doing_product_audit() RETURNS TRIGGER AS $doing_product_audit$
    BEGIN
		IF (TG_OP = 'INSERT') THEN
			INSERT INTO doing_product_audit SELECT NEW.identifier, 'insert', now(), now();
			RETURN NEW;
        ELSIF (TG_OP = 'DELETE') THEN
            INSERT INTO doing_product_audit SELECT OLD.identifier, 'delete', now(), now();
            RETURN OLD;
        END IF;
        RETURN NULL;
    END;
$doing_product_audit$ LANGUAGE plpgsql;

CREATE TRIGGER doing_product_audit AFTER INSERT OR DELETE ON doing_product FOR EACH ROW EXECUTE PROCEDURE process_doing_product_audit();
-- 以上跟微博相关

-- 以下跟评论相关
DROP SEQUENCE IF EXISTS "comment_seq" CASCADE;
CREATE SEQUENCE comment_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER TABLE comment_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE comment_seq
  IS '用来生成comment表的标识符';

DROP TABLE IF EXISTS "comment" CASCADE;
CREATE TABLE "comment" (
"identifier" character varying(50) NOT NULL,
"member" character varying(50) NOT NULL DEFAULT '',
"owner" character varying(50) NOT NULL DEFAULT '',
"owner_type" character varying(20) NOT NULL DEFAULT '',
"content" character varying(200) NOT NULL DEFAULT '',
"comment_id" character varying(50) NOT NULL DEFAULT '',
"comment_id_type" character varying(50) NOT NULL DEFAULT '',
"to_family" character varying(50) NOT NULL DEFAULT '',
"post_ip" character varying(20) NOT NULL DEFAULT '',
"enabled" boolean NOT NULL DEFAULT true,
"reply_comment_id" character varying(50) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now(),
"comment_pic" character varying(500) NOT NULL DEFAULT '',
);
ALTER TABLE "comment" ADD CONSTRAINT "comment_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "comment" IS '评论';
COMMENT ON COLUMN "comment"."identifier" IS '评论标识符';
COMMENT ON COLUMN "comment"."member" IS '发表评论的会员：参照member表中的identifier字段';
COMMENT ON COLUMN "comment"."owner" IS '评论的所有者';
COMMENT ON COLUMN "comment"."owner_type" IS '评论的所有者类型：family-家、community-社区、company-企业、organization-机构';
COMMENT ON COLUMN "comment"."content" IS '内容';
COMMENT ON COLUMN "comment"."comment_id" IS '被评论的标识符';
COMMENT ON COLUMN "comment"."comment_id_type" IS '被评论的标识符类型：discuss-话题、comDiscuss-话题评论、doingid-微博标识符、pictorial-画报识符';
COMMENT ON COLUMN "comment"."to_family" IS '评论谁的家:参照family表中doorplate或member中family';
COMMENT ON COLUMN "comment"."post_ip" IS '发表评论的ip';
COMMENT ON COLUMN "comment"."enabled" IS '评论是否可用：true-可用、false-不可用';
COMMENT ON COLUMN "comment"."reply_comment_id" IS '对微博评论再评论,记录上一条评论id：参照comment表中identifier';
COMMENT ON COLUMN "comment"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "comment"."gmt_modified" IS '最后修改时间戳';
COMMENT ON COLUMN "comment"."comment_pic" IS '评论的图片';
-- 以上跟评论相关

-- 以下跟提到我的相关
DROP SEQUENCE IF EXISTS "mention_seq" CASCADE;
CREATE SEQUENCE mention_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER TABLE mention_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE mention_seq
  IS '用来生成mention表的标识符';

DROP TABLE IF EXISTS "mention" CASCADE;
CREATE TABLE "mention" (
"identifier" character varying(50) NOT NULL,
"member" character varying(50) NOT NULL DEFAULT '',
"family" character varying(50) NOT NULL DEFAULT '',
"mention_type" character varying(50) NOT NULL DEFAULT '',
"mention_id" character varying(50) NOT NULL DEFAULT '',
"is_read" boolean NOT NULL DEFAULT false,
"mention_ip" character varying(50) NOT NULL DEFAULT '',
"enabled" boolean NOT NULL DEFAULT true,
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "mention" ADD CONSTRAINT "mention_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "mention" IS '提到我家的';
COMMENT ON COLUMN "mention"."identifier" IS '提到我家的标识符';
COMMENT ON COLUMN "mention"."member" IS '提到我家的会员ID：参照member表中的identifier字段';
COMMENT ON COLUMN "mention"."family" IS '被提到的家庭（即我家）的门牌号：参照family表中的doorplate字段';
COMMENT ON COLUMN "mention"."mention_type" IS '被提到的类型：commentId(friend-交友中被提到、album-相册中被提到、doing-微博中被提到、blog-日志中动态、profile-会员基本资料中被提到);relayId(转播提到);nameId(@符提到);crowdTopicReplyId(群话题的回复提到我家的)';
COMMENT ON COLUMN "mention"."mention_id" IS '提到我家的对应类型表里的ID';
COMMENT ON COLUMN "mention"."is_read" IS '提到我家的信息是否已经阅读：true-已阅读；false-未阅读';
COMMENT ON COLUMN "mention"."mention_ip" IS '记录提到我家的会员的IP';
COMMENT ON COLUMN "mention"."enabled" IS '是否激活';
COMMENT ON COLUMN "mention"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "mention"."gmt_modified" IS '最后修改时间戳';
-- 以上跟提到我的相关

/*
-- 以下跟帖吧相关
DROP TABLE IF EXISTS "forum" CASCADE;
CREATE TABLE "forum" (
"identifier" character varying(50) NOT NULL,
"name" character varying(50) NOT NULL DEFAULT '',
"creator" character varying(50) NOT NULL DEFAULT '',
"introduction" character varying(500) NOT NULL DEFAULT '',
"image_server" character varying(500) NOT NULL DEFAULT '',
"logo" character varying(300) NOT NULL DEFAULT '',
"background_image" character varying(500) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "forum" ADD CONSTRAINT "forum_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "forum" IS '帖吧';
COMMENT ON COLUMN "forum"."identifier" IS '帖吧标识符';
COMMENT ON COLUMN "forum"."name" IS '帖吧名';
COMMENT ON COLUMN "forum"."creator" IS '帖吧的创建者：参照member表中的identifier字段';
COMMENT ON COLUMN "forum"."introduction" IS '帖吧的简介';
COMMENT ON COLUMN "forum"."image_server" IS '帖吧LOGO图片存放的服务器地址';
COMMENT ON COLUMN "forum"."logo" IS '帖吧LOGO图片在图片服务器上的保存路径';
COMMENT ON COLUMN "forum"."background_image" IS '帖吧皮肤';
COMMENT ON COLUMN "forum"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "forum"."gmt_modified" IS '最后修改时间戳';

DROP TABLE IF EXISTS "forum_member" CASCADE;
CREATE TABLE "forum_member" (
"forum" character varying(50) NOT NULL,
"member" character varying(50) NOT NULL,
"role" char(2) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "forum_member" ADD CONSTRAINT "forum_member_pk" PRIMARY KEY("forum","member");
COMMENT ON TABLE "forum_member" IS '帖吧和会员的交叉关系表';
COMMENT ON COLUMN "forum_member"."forum" IS '帖吧标识符：参照forum表中的identifier字段';
COMMENT ON COLUMN "forum_member"."member" IS '会员标识：参照member表中的identifier字段';
COMMENT ON COLUMN "forum_member"."role" IS '会员在帖吧里的角色：01-群主、02-管理员';
COMMENT ON COLUMN "forum_member"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "forum_member"."gmt_modified" IS '最后修改时间戳';

DROP TABLE IF EXISTS "forum_hot_doing" CASCADE;
CREATE TABLE "forum_hot_doing"(
"identifier" character varying(50) NOT NULL,
"forum" character varying(50) NOT NULL DEFAULT '',
"image_server"  character varying(500) NOT NULL DEFAULT '',
"pic_doing" character varying(300) NOT NULL DEFAULT '',
"title" character varying(500) NOT NULL DEFAULT '',
"doing_link" character varying(500) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "forum_hot_doing" ADD CONSTRAINT "forum_hot_doing_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "forum_hot_doing" IS '热帖表';
COMMENT ON COLUMN "forum_hot_doing"."identifier" IS '热帖的标识';
COMMENT ON COLUMN "forum_hot_doing"."forum" IS '热贴属于的帖吧标识';
COMMENT ON COLUMN "forum_hot_doing"."image_server" IS '热帖图标的服务器';
COMMENT ON COLUMN "forum_hot_doing"."pic_doing" IS '热帖图标的地址';
COMMENT ON COLUMN "forum_hot_doing"."title" IS '热帖的标题';
COMMENT ON COLUMN "forum_hot_doing"."doing_link" IS '热帖的链接';
COMMENT ON COLUMN "forum_hot_doing"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "forum_hot_doing"."gmt_modified" IS '最后修改时间戳';
--以上跟帖吧相关
*/

--喜欢我的
DROP SEQUENCE IF EXISTS "doing_love_seq" CASCADE;
CREATE SEQUENCE doing_love_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER TABLE doing_love_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE doing_love_seq
  IS '用来生成doing_love表的标识符';

DROP TABLE IF EXISTS "doing_love" CASCADE;
CREATE TABLE "doing_love"(
"identifier" character varying(50) NOT NULL,
"doing" character varying(50) NOT NULL DEFAULT '',
"create_member"  character varying(50) NOT NULL DEFAULT '',
"create_owner" character varying(50) NOT NULL DEFAULT '',
"create_owner_type" character varying(50) NOT NULL DEFAULT '',
"create_doing" character varying(50) DEFAULT ''::character varying, 
"receive_member" character varying(50) NOT NULL DEFAULT ''::character varying,
"receive_owner" character varying(50) DEFAULT ''::character varying, 
"receive_owner_type" character varying(50) DEFAULT ''::character varying, 
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "doing_love" ADD CONSTRAINT "doing_love_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "doing_love" IS '喜欢我的表';
COMMENT ON COLUMN "doing_love"."identifier" IS '标识';
COMMENT ON COLUMN "doing_love"."doing" IS '喜欢的微博';
COMMENT ON COLUMN "doing_love"."create_member" IS '产生喜欢记录的人';
COMMENT ON COLUMN "doing_love"."create_owner" IS'';
COMMENT ON COLUMN "doing_love"."create_owner_type" IS'';
COMMENT ON COLUMN "doing_love"."create_doing" IS '喜欢产生的微博ID';
COMMENT ON COLUMN "doing_love"."receive_member" IS '被喜欢的人';
COMMENT ON COLUMN "doing_love"."receive_owner" IS '';
COMMENT ON COLUMN "doing_love"."receive_owner_type" IS '';
COMMENT ON COLUMN "doing_love"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "doing_love"."gmt_modified" IS '最后修改时间戳';

/*
---抢话费活动
DROP SEQUENCE IF EXISTS "rush_seq" CASCADE;
CREATE SEQUENCE rush_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER TABLE rush_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE rush_seq
  IS '用来生成rush表的标识符';

DROP TABLE IF EXISTS "rush" CASCADE;
CREATE TABLE "rush" (
"identifier" character varying(50) NOT NULL,
"title" character varying(50) NOT NULL DEFAULT '',
"enabled" boolean NOT NULL DEFAULT true,
"start_date" character varying(10) NOT NULL DEFAULT '',
"end_date" character varying(10) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "rush" ADD CONSTRAINT "rush_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "rush" IS '表';
COMMENT ON COLUMN "rush"."identifier" IS '抢话费活动识符';
COMMENT ON COLUMN "rush"."title" IS '抢话费活动标题';
COMMENT ON COLUMN "rush"."enabled" IS '活动是否可用';
COMMENT ON COLUMN "rush"."start_date" IS '开始日期/年月日';
COMMENT ON COLUMN "rush"."end_date" IS '结束日期/年月日';
COMMENT ON COLUMN "rush"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "rush"."gmt_modified" IS '最后修改时间戳';


DROP SEQUENCE IF EXISTS "rush_plan_seq" CASCADE;
CREATE SEQUENCE rush_plan_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER TABLE rush_plan_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE rush_plan_seq
  IS '用来生成rush_plan表的标识符';


 DROP TABLE IF EXISTS "rush_plan" CASCADE;
CREATE TABLE "rush_plan" (
"identifier" character varying(50) NOT NULL,
"rush_id" character varying(50) NOT NULL,
 "type" character varying(20) NOT NULL DEFAULT '',
 "name" character varying(20) NOT NULL DEFAULT '',
 "link_url" character varying(500) NOT NULL DEFAULT '',
 "plan_class" character varying(20) NOT NULL DEFAULT '',
"pic_url" character varying(500) NOT NULL DEFAULT '',
"image_sever"  character varying(500) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "rush_plan" ADD CONSTRAINT "rush_plan_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "rush" IS '表';
COMMENT ON COLUMN "rush_plan"."identifier" IS '抢话费事件识符';
COMMENT ON COLUMN "rush_plan"."type" IS '奖项类型-02一日内唯一，03活动期内唯一';
COMMENT ON COLUMN "rush_plan"."name" IS '奖项名';
COMMENT ON COLUMN "rush_plan"."rush_id" IS '事件属于的活动,对应rush表的identifier';
COMMENT ON COLUMN "rush_plan"."link_url" IS '特殊事件：广告等的超链接地址';
COMMENT ON COLUMN "rush_plan"."plan_class" IS '事件的类型：01宝、02广告';
COMMENT ON COLUMN "rush_plan"."pic_url" IS '抢话费图片地址';
COMMENT ON COLUMN "rush_plan"."image_sever" IS '图片服务器地址';
COMMENT ON COLUMN "rush_plan"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "rush_plan"."gmt_modified" IS '最后修改时间戳';

DROP SEQUENCE IF EXISTS "rush_time_seq" CASCADE;
CREATE SEQUENCE rush_time_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER TABLE rush_time_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE rush_time_seq
  IS '用来生成rush_time表的标识符';

DROP TABLE IF EXISTS "rush_time" CASCADE;
CREATE TABLE "rush_time" (
"identifier" character varying(50) NOT NULL,
"rush_plan_id" character varying(50) NOT NULL,
"start_time" character varying(20) NOT NULL DEFAULT '',
"end_time" character varying(20) NOT NULL DEFAULT '',
"count" integer NOT NULL DEFAULT 0,
"custom_count" integer NOT NULL DEFAULT 0,
"enabled" boolean NOT NULL DEFAULT true,
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "rush_time" ADD CONSTRAINT "rush_time_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "rush_time" IS '抢话费时间表';
COMMENT ON COLUMN "rush_time"."identifier" IS '抢话费时间标识符';
COMMENT ON COLUMN "rush_time"."rush_plan_id" IS '对应rush_plan表的identifier';
COMMENT ON COLUMN "rush_time"."start_time" IS '抢话费开始时间';
COMMENT ON COLUMN "rush_time"."end_time" IS '抢话费结束时间';
COMMENT ON COLUMN "rush_time"."count" IS '抢话费的数量';
COMMENT ON COLUMN "rush_time"."custom_count" IS '日常活动每天默认数量';
COMMENT ON COLUMN "rush_time"."enabled" IS '抢话费时间段是否可用';
COMMENT ON COLUMN "rush_time"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "rush_time"."gmt_modified" IS '最后修改时间戳';


DROP SEQUENCE IF EXISTS "rush_time_part_seq" CASCADE;
CREATE SEQUENCE rush_time_part_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER TABLE rush_time_part_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE rush_time_part_seq
  IS '用来生成rush_time_part表的标识符';

DROP TABLE IF EXISTS "rush_time_part" CASCADE;
CREATE TABLE "rush_time_part" (
"identifier" character varying(50) NOT NULL,
"rush_time_id" character varying(50) NOT NULL,
"part_start_time" character varying(20) NOT NULL DEFAULT '',
"part_end_time" character varying(20) NOT NULL DEFAULT '',
"part_count" integer NOT NULL DEFAULT 0,
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"rush_plan_id" character varying(50) NOT NULL DEFAULT '',
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "rush_time_part" ADD CONSTRAINT "rush_time_part_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "rush_time_part" IS '抢话费时间分段表';
COMMENT ON COLUMN "rush_time_part"."identifier" IS '抢话费分段时间标识符';
COMMENT ON COLUMN "rush_time_part"."rush_time_id" IS '对应rush_time表的identifier';
COMMENT ON COLUMN "rush_time_part"."part_start_time" IS '开始时间';
COMMENT ON COLUMN "rush_time_part"."part_end_time" IS '结束时间';
COMMENT ON COLUMN "rush_time_part"."part_count" IS '数量';
COMMENT ON COLUMN "rush_time_part"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "rush_time_part"."rush_plan_id" IS '对应rush_plan表的identifier';
COMMENT ON COLUMN "rush_time_part"."gmt_modified" IS '最后修改时间戳';

DROP TABLE IF EXISTS "rush_phone" CASCADE;
CREATE TABLE "rush_phone" (
"phone_number" character varying(50) NOT NULL,
"family" character varying(50) NOT NULL,
"member" character varying(50) NOT NULL,
"rush_plan_id" character varying(50) NOT NULL,
"rush_ip" character varying(50) NOT NULL DEFAULT '',
"enabled" boolean NOT NULL DEFAULT true,
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "rush_phone" ADD CONSTRAINT "rush_phone_pk" PRIMARY KEY("phone_number","rush_plan_id");
COMMENT ON TABLE "rush_phone" IS '抢中话费手机号码表';
COMMENT ON COLUMN "rush_phone"."phone_number" IS '抢中话费的手机号码';
COMMENT ON COLUMN "rush_phone"."family" IS '抢中话费的家庭号-对应family表的doorplate';
COMMENT ON COLUMN "rush_phone"."member" IS '抢中话费的成员号-对应member表的identifier';
COMMENT ON COLUMN "rush_phone"."rush_plan_id" IS '对应rush_plan表的identifier';
COMMENT ON COLUMN "rush_phone"."rush_ip" IS '领奖ip地址';
COMMENT ON COLUMN "rush_phone"."enabled" IS '是否抢成功--true 成功--false 失败';
COMMENT ON COLUMN "rush_phone"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "rush_phone"."gmt_modified" IS '最后修改时间戳';
*/


DROP TABLE IF EXISTS "doing_pictorial_topic" CASCADE;
CREATE TABLE "public"."doing_pictorial_topic" (
"pictorial" varchar(50) DEFAULT ''::character varying NOT NULL,
"pictorial_topic" varchar(50) DEFAULT ''::character varying NOT NULL,
"gmt_created" timestamptz(6) DEFAULT now() NOT NULL,
"gmt_modified" timestamptz(6) DEFAULT now() NOT NULL,
"sort" int4 DEFAULT 0,
CONSTRAINT "doing_pictorial_topic_pkey" PRIMARY KEY ("pictorial", "pictorial_topic")
)
ALTER TABLE "public"."doing_pictorial_topic" OWNER TO "guoguojie";
COMMENT ON TABLE "public"."doing_pictorial_topic" IS '画报和画报主题的交叉表';
COMMENT ON COLUMN "public"."doing_pictorial_topic"."pictorial" IS '画报的ID，参照doing_pictorial表的identifier字段';
COMMENT ON COLUMN "public"."doing_pictorial_topic"."pictorial_topic" IS '画报主题的ID，参照pictorial_topic表的identifier字段';
COMMENT ON COLUMN "public"."doing_pictorial_topic"."sort" IS '画报在主题中的排序';

DROP SEQUENCE IF EXISTS "pictorial_topic_seq" CASCADE;
CREATE SEQUENCE pictorial_topic_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER TABLE pictorial_topic_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE pictorial_topic_seq
  IS '用来生成pictorial_topic表的标识符';

DROP TABLE IF EXISTS "pictorial_topic" CASCADE;
CREATE TABLE "public"."pictorial_topic" (
"identifier" varchar(50) DEFAULT ''::character varying NOT NULL,
"name" varchar(50) DEFAULT ''::character varying NOT NULL,
"gmt_created" timestamptz(6) DEFAULT now() NOT NULL,
"gmt_modified" timestamptz(6) DEFAULT now() NOT NULL,
"description" varchar(500) DEFAULT ''::character varying NOT NULL,
"is_lock" bool DEFAULT false NOT NULL,
"view_amount" int4 DEFAULT 0 NOT NULL,
"type" varchar(2) DEFAULT '01'::character varying,
"image1" varchar(300) DEFAULT ''::character varying,
"image2" varchar(300),
"image3" varchar(300),
"image3" varchar(300),
"sort" int4 DEFAULT 0,
"bonus" varchar(50),
CONSTRAINT "pictorial_topic_pkey" PRIMARY KEY ("identifier")
)
WITH (OIDS=FALSE);
ALTER TABLE "public"."pictorial_topic" OWNER TO "guoguojie";
COMMENT ON TABLE "public"."pictorial_topic" IS '画报的主题';
COMMENT ON COLUMN "public"."pictorial_topic"."type" IS '01:普通主题 02:试用主题';

DROP SEQUENCE IF EXISTS "doing_stat_seq" CASCADE;
CREATE SEQUENCE doing_stat_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER TABLE doing_stat_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE doing_stat_seq
  IS '用来生成doing_stat表的标识符';

DROP TABLE IF EXISTS "doing_stat" CASCADE;
CREATE TABLE "doing_stat" (
"identifier" character varying(50) NOT NULL,
"doing" character varying(50) NOT NULL,
"view_ip" character varying(50) NOT NULL,
"ip_view_count" integer NOT NULL DEFAULT 0,
"last_view_time" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "doing_stat" ADD CONSTRAINT "doing_stat_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "doing_stat" IS '微博IP统计表';
COMMENT ON COLUMN "doing_stat"."identifier" IS '标识符';
COMMENT ON COLUMN "doing_stat"."doing" IS '微博ID';
COMMENT ON COLUMN "doing_stat"."view_ip" IS '访问IP';
COMMENT ON COLUMN "doing_stat"."ip_view_count" IS '访问次数';
COMMENT ON COLUMN "doing_stat"."last_view_time" IS '上一次访问时间';
COMMENT ON COLUMN "doing_stat"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "doing_stat"."gmt_modified" IS '最后修改时间戳';
CREATE UNIQUE INDEX "doing_stat_doing_view_ip" ON "doing_stat" USING btree ("doing","view_ip");

/*
--以下跟逛有关
DROP TABLE IF EXISTS "stroll" CASCADE;
CREATE TABLE "stroll" (
"identifier" character varying(50) NOT NULL,
"name" character varying(50) NOT NULL DEFAULT '',
"introduction" character varying(500) NOT NULL DEFAULT '',
"image_server" character varying(500) NOT NULL DEFAULT '',
"logo" character varying(300) NOT NULL DEFAULT '',
"top_img" character varying(500) NOT NULL DEFAULT '',
"keyword" character varying(20) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "stroll" ADD CONSTRAINT "stroll_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "stroll" IS '逛';
COMMENT ON COLUMN "stroll"."identifier" IS '逛标识符';
COMMENT ON COLUMN "stroll"."name" IS '逛名称';
COMMENT ON COLUMN "stroll"."introduction" IS '逛的简介';
COMMENT ON COLUMN "stroll"."image_server" IS '逛LOGO图片存放的服务器地址';
COMMENT ON COLUMN "stroll"."logo" IS '逛LOGO图片保存路径';
COMMENT ON COLUMN "stroll"."top_img" IS '逛皮肤';
COMMENT ON COLUMN "stroll"."keyword" IS '逛街的关键词';
COMMENT ON COLUMN "stroll"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "stroll"."gmt_modified" IS '最后修改时间戳';

DROP TABLE IF EXISTS "stroll_class" CASCADE;
CREATE TABLE "stroll_class" (
"identifier" varchar(50) NOT NULL,
"stroll_id" varchar(50) DEFAULT ''::character varying NOT NULL,
"class_name" varchar(50) DEFAULT ''::character varying NOT NULL,
"content" character varying(500) NOT NULL DEFAULT '',
"image_server" character varying(500) NOT NULL DEFAULT '',
"back_img" character varying(300) NOT NULL DEFAULT '',
"sort" integer NOT NULL DEFAULT 0,
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "stroll_class" ADD CONSTRAINT "stroll_class_pk" PRIMARY KEY("identifier");
COMMENT ON COLUMN "stroll_class"."identifier" IS '逛分类标识符';
COMMENT ON COLUMN "stroll_class"."stroll_id" IS '分类所有者，对应表stroll中identifier';
COMMENT ON COLUMN "stroll_class"."class_name" IS '分类名字';
COMMENT ON COLUMN "stroll_class"."content" IS '分类的内容';
COMMENT ON COLUMN "stroll_class"."image_server" IS '分类LOGO图片存放的服务器地址';
COMMENT ON COLUMN "stroll_class"."back_img" IS '分类LOGO图片保存路径';
COMMENT ON COLUMN "stroll_class"."sort" IS '分类排序';
COMMENT ON COLUMN "stroll_class"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "stroll_class"."gmt_modified" IS '最后修改时间戳';

DROP TABLE IF EXISTS "stroll_goods" CASCADE;
CREATE TABLE "stroll_goods"(
"identifier" character varying(50) NOT NULL,
"stroll_id" character varying(50) NOT NULL DEFAULT '',
"class_id" character varying(50) NOT NULL DEFAULT '',
"image_server"  character varying(500) NOT NULL DEFAULT '',
"goods_pic" character varying(300) NOT NULL DEFAULT '',
"title" character varying(500) NOT NULL DEFAULT '',
"goods_link" character varying(500) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "stroll_goods" ADD CONSTRAINT "stroll_goods_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "stroll_goods" IS '逛街实物表';
COMMENT ON COLUMN "stroll_goods"."identifier" IS '实物的标识';
COMMENT ON COLUMN "stroll_goods"."stroll_id" IS '实物属于的逛标识，对应表stroll中identifier';
COMMENT ON COLUMN "stroll_goods"."class_id" IS '实物属于分类的表示，对应表stroll_class中identifier';
COMMENT ON COLUMN "stroll_goods"."image_server" IS '实物图标的服务器';
COMMENT ON COLUMN "stroll_goods"."goods_pic" IS '实物图标的地址';
COMMENT ON COLUMN "stroll_goods"."title" IS '实物的标题';
COMMENT ON COLUMN "stroll_goods"."goods_link" IS '实物的链接';
COMMENT ON COLUMN "stroll_goods"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "stroll_goods"."gmt_modified" IS '最后修改时间戳';
--以上跟逛街有关
*/

--以下跟红利社有关
DROP SEQUENCE IF EXISTS "bonus_seq" CASCADE;
CREATE SEQUENCE bonus_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER TABLE bonus_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE bonus_seq
  IS '用来生成bonus表的标识符';

DROP TABLE IF EXISTS "bonus" CASCADE;
CREATE TABLE "bonus"(
"identifier" character varying(50) NOT NULL,
"name" character varying(50) NOT NULL DEFAULT '',
"class_name" character varying(50) NOT NULL DEFAULT '',
"intro"  character varying(1024) NOT NULL DEFAULT '',
"apply_req" text NOT NULL DEFAULT '',
"try_req" text NOT NULL DEFAULT '',
"end_req" text NOT NULL DEFAULT '',
"from_url"  character varying(500) NOT NULL DEFAULT '',
"apply_start" character varying(20) NOT NULL DEFAULT '',
"apply_end" character varying(20) NOT NULL DEFAULT '',
"try_end" character varying(20) NOT NULL DEFAULT '',
"amount" int4 DEFAULT 0 NOT NULL,
"leave_amount" int4 DEFAULT 0 NOT NULL,
"view_amount" int4 DEFAULT 0 NOT NULL,
"apply_nums" int4 DEFAULT 0 NOT NULL,
"image_server" character varying(500) NOT NULL DEFAULT '',
"image_url" character varying(500) NOT NULL DEFAULT '',
"type" character varying(2) NOT NULL DEFAULT '01',
"enabled" boolean NOT NULL DEFAULT false,
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "bonus" ADD CONSTRAINT "bonus_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "bonus" IS '红利表';
COMMENT ON COLUMN "bonus"."identifier" IS '红利的标识';
COMMENT ON COLUMN "bonus"."name" IS '红利名称';
COMMENT ON COLUMN "bonus"."class_name" IS '红利品牌名称';
COMMENT ON COLUMN "bonus"."intro" IS '红利介绍';
COMMENT ON COLUMN "bonus"."apply_req" IS '申请要求';
COMMENT ON COLUMN "bonus"."try_req" IS '试用报告要求';
COMMENT ON COLUMN "bonus"."end_req" IS '试用结束后的要求';
COMMENT ON COLUMN "bonus"."from_url" IS '产品详细地址的url';
COMMENT ON COLUMN "bonus"."apply_start" IS '红利开始申请时间';
COMMENT ON COLUMN "bonus"."apply_end" IS '红利结束申请时间';
COMMENT ON COLUMN "bonus"."try_end" IS '红利试用结束时间';
COMMENT ON COLUMN "bonus"."amount" IS '红利提供试用的数量';
COMMENT ON COLUMN "bonus"."leave_amount" IS '红利提供试用的剩下的数量';
COMMENT ON COLUMN "bonus"."view_amount" IS '红利的人气';
COMMENT ON COLUMN "bonus"."apply_nums" IS '红利申请的人数';
COMMENT ON COLUMN "bonus"."image_server" IS '红利图片的服务器地址';
COMMENT ON COLUMN "bonus"."image_url" IS '红利的图片地址';
COMMENT ON COLUMN "bonus"."type" IS '红利的类型(01、产品)';
COMMENT ON COLUMN "bonus"."enabled" IS '红利前台是否可用';
COMMENT ON COLUMN "bonus"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "bonus"."gmt_modified" IS '最后修改时间戳';


DROP TABLE IF EXISTS "bonus_apply" CASCADE;
CREATE TABLE "bonus_apply"(
"bonus" character varying(50) NOT NULL,
"member" character varying(50) NOT NULL,
"family" character varying(50) NOT NULL,
"doing" character varying(50) NOT NULL,
"memo" character varying(3000) NOT NULL DEFAULT '',
"status" character varying(2) NOT NULL DEFAULT '01',
"enabled" boolean NOT NULL DEFAULT true,
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "bonus_apply" ADD CONSTRAINT "bonus_apply_pk" PRIMARY KEY("bonus","family");
COMMENT ON TABLE "bonus_apply" IS '申请红利的表';
COMMENT ON COLUMN "bonus_apply"."bonus" IS '对应红利表的identifier';
COMMENT ON COLUMN "bonus_apply"."member" IS '申请的人的号 对应member表的identifier';
COMMENT ON COLUMN "bonus_apply"."family" IS '申请的人的家庭号 对应family表的doorplate';
COMMENT ON COLUMN "bonus_apply"."doing" IS '申请的时候发布的微博号，对应doing表的identifier';
COMMENT ON COLUMN "bonus_apply"."memo" IS '申请时候的备注信息';
COMMENT ON COLUMN "bonus_apply"."status" IS '申请人的状态(01、正在申请 02、审核通过)';
COMMENT ON COLUMN "bonus_apply"."enabled" IS '前台是否显示';
COMMENT ON COLUMN "bonus_apply"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "bonus_apply"."gmt_modified" IS '最后修改时间戳';

--以上跟红利社有关

--以下跟货币系统有关
DROP SEQUENCE IF EXISTS "account_seq" CASCADE;
CREATE SEQUENCE account_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER TABLE account_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE account_seq
  IS '用来生成account表的标识符';

DROP TABLE IF EXISTS "account" CASCADE;
CREATE TABLE "account" (
"identifier" character varying(50) NOT NULL,
"member" character varying(50) NOT NULL,
"name" character varying(50) NOT NULL DEFAULT '',
"rmb" numeric(12,2) NOT NULL DEFAULT '0.00',
"ggb" numeric(12,2) NOT NULL DEFAULT '0.00',
"remark" text NOT NULL DEFAULT '',
"enabled" boolean NOT NULL DEFAULT true,
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "account" ADD CONSTRAINT "account_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "account" IS '货币账户';
COMMENT ON COLUMN "account"."identifier" IS '账户标识符';
COMMENT ON COLUMN "account"."member" IS '账户所属于的会员：参考表member中的identifier字段';
COMMENT ON COLUMN "account"."name" IS '账户名称';
COMMENT ON COLUMN "account"."rmb" IS '人民币余额';
COMMENT ON COLUMN "account"."ggb" IS '果果币余额';
COMMENT ON COLUMN "account"."remark" IS '备注';
COMMENT ON COLUMN "account"."enabled" IS '账户是否可用';
COMMENT ON COLUMN "account"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "account"."gmt_modified" IS '最后修改时间戳';
CREATE UNIQUE INDEX "account_idx_member" ON "account" USING btree ("member");

DROP SEQUENCE IF EXISTS "account_log_seq" CASCADE;
CREATE SEQUENCE account_log_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER TABLE account_log_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE account_log_seq
  IS '用来生成account_log表的标识符';

DROP TABLE IF EXISTS "account_log" CASCADE;
CREATE TABLE "account_log" (
"identifier" character varying(50) NOT NULL,
"account" character varying(50) NOT NULL,
"transaction_time" timestamp with time zone,
"transaction_type" character varying(50) NOT NULL,
"deposit_rmb" numeric(12,2) NOT NULL DEFAULT '0.00',
"deposit_rmb_account" character varying(50) NOT NULL DEFAULT '',
"withdraw_rmb" numeric(12,2) NOT NULL DEFAULT '0.00',
"withdraw_rmb_account" character varying(50) NOT NULL DEFAULT '',
"rmb" numeric(12,2) NOT NULL,
"deposit_ggb" numeric(12,2) NOT NULL DEFAULT '0.00',
"deposit_ggb_account" character varying(50) NOT NULL DEFAULT '',
"withdraw_ggb" numeric(12,2) NOT NULL DEFAULT '0.00',
"withdraw_ggb_account" character varying(50) NOT NULL DEFAULT '',
"ggb" numeric(12,2) NOT NULL,
"summary" text NOT NULL DEFAULT '',
"operator" character varying(50) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "account_log" ADD CONSTRAINT "account_log_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "account_log" IS '账户交易日志';
COMMENT ON COLUMN "account_log"."identifier" IS '账户交易日志标识符';
COMMENT ON COLUMN "account_log"."account" IS '交易日志所属账户，参照表account中的identifier字段';
COMMENT ON COLUMN "account_log"."transaction_time" IS '交易时间';
COMMENT ON COLUMN "account_log"."transaction_type" IS '交易类型：rmb-人民币交易、ggb-果果币交易、operate-果果街后台操作';
COMMENT ON COLUMN "account_log"."deposit_rmb" IS '人民币存入金额';
COMMENT ON COLUMN "account_log"."deposit_rmb_account" IS '存入人民币的帐户：参照表account中的identifier字段';
COMMENT ON COLUMN "account_log"."withdraw_rmb" IS '人民币支出金额';
COMMENT ON COLUMN "account_log"."withdraw_rmb_account" IS '支出人民币的帐户：参照表account中的identifier字段';
COMMENT ON COLUMN "account_log"."rmb" IS '人民币余额';
COMMENT ON COLUMN "account_log"."deposit_ggb" IS '果果币存入金额';
COMMENT ON COLUMN "account_log"."deposit_ggb_account" IS '存入果果币的帐户：参照表account中的identifier字段';
COMMENT ON COLUMN "account_log"."withdraw_ggb" IS '果果币支出金额';
COMMENT ON COLUMN "account_log"."withdraw_ggb_account" IS '支出果果币的帐户：参照表account中的identifier字段';
COMMENT ON COLUMN "account_log"."rmb" IS '果果币余额';
COMMENT ON COLUMN "account_log"."summary" IS '交易摘要';
COMMENT ON COLUMN "account_log"."operator" IS '如果是果果街后台操作，则记录后台帐号的用户名：参照表admin_user中的realname字段';
COMMENT ON COLUMN "account_log"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "account_log"."gmt_modified" IS '最后修改时间戳';

DROP SEQUENCE IF EXISTS "account_draw_apply_seq" CASCADE;
CREATE SEQUENCE account_draw_apply_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER TABLE account_draw_apply_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE account_draw_apply_seq
  IS '用来生成account_draw_apply表的标识符';

DROP TABLE IF EXISTS "account_draw_apply" CASCADE;
CREATE TABLE "account_draw_apply" (
"identifier" character varying(50) NOT NULL DEFAULT nextval('account_draw_apply_seq'),
"account" character varying(50) NOT NULL,
"draw_rmb" numeric(12,2) NOT NULL DEFAULT '0.00',
"nickname" character varying(50) NOT NULL DEFAULT '',
"apply_time" timestamp with time zone,
"draw_type" character varying(50) NOT NULL DEFAULT '',
"alipay" character varying(50) NOT NULL DEFAULT '',
"bank_num" character varying(50) NOT NULL DEFAULT '',
"bank_name" character varying(50) NOT NULL DEFAULT '',
"realname" character varying(50) NOT NULL DEFAULT '',
"status" character varying(50) NOT NULL DEFAULT '',
"summary" text NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "account_draw_apply" ADD CONSTRAINT "account_draw_apply_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "account_draw_apply" IS '账户提现申请表';
COMMENT ON COLUMN "account_draw_apply"."identifier" IS '账户提现申请表标识符';
COMMENT ON COLUMN "account_draw_apply"."account" IS '提现账户，参照表account中的identifier字段';
COMMENT ON COLUMN "account_draw_apply"."draw_rmb" IS '提现金额';
COMMENT ON COLUMN "account_draw_apply"."nickname" IS '提现会员昵称';
COMMENT ON COLUMN "account_draw_apply"."apply_time" IS '提现申请时间';
COMMENT ON COLUMN "account_draw_apply"."draw_type" IS '提现方式：01-支付宝，02-银行卡';
COMMENT ON COLUMN "account_draw_apply"."alipay" IS '支付宝帐号，提现方式为01时生效';
COMMENT ON COLUMN "account_draw_apply"."bank_num" IS '银行卡号，提现方式为02时生效';
COMMENT ON COLUMN "account_draw_apply"."bank_name" IS '开户银行名字，提现方式为02时生效';
COMMENT ON COLUMN "account_draw_apply"."realname" IS '提现会员的真实姓名';
COMMENT ON COLUMN "account_draw_apply"."status" IS '提现申请处理状态：01-申请中，02-已完成';
COMMENT ON COLUMN "account_draw_apply"."summary" IS '提现摘要';
COMMENT ON COLUMN "account_draw_apply"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "account_draw_apply"."gmt_modified" IS '最后修改时间戳';
--以上跟货币系统有关


/*
-- 以下跟订单系统相关
DROP TABLE IF EXISTS "product_category" CASCADE;
CREATE TABLE "product_category" (
"identifier" character varying(50) NOT NULL,
"parent_identifier" character varying(50) NOT NULL DEFAULT '0',
"name" character varying(50) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "product_category" ADD CONSTRAINT "product_category_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "product_category" IS '产品类目';
COMMENT ON COLUMN "product_category"."identifier" IS '类目标识符';
COMMENT ON COLUMN "product_category"."parent_identifier" IS '父类目标识符';
COMMENT ON COLUMN "product_category"."name" IS '名字';
COMMENT ON COLUMN "product_category"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "product_category"."gmt_modified" IS '最后修改时间戳';

DROP TABLE IF EXISTS "product" CASCADE;
CREATE TABLE "product" (
"identifier" character varying(50) NOT NULL,
"company" character varying(50) NOT NULL,
"member" character varying(50) NOT NULL,
"category" character varying(50) NOT NULL,
"title" character varying(100) NOT NULL DEFAULT '',
"brand" character varying(50),
"specification" character varying(100),
"min_use_age" character varying(20),
"max_use_age" character varying(20),
"description" text NOT NULL DEFAULT '',
"image_server" character varying(500) NOT NULL DEFAULT '',
"cover" character varying(500) NOT NULL DEFAULT '',
"img1" character varying(500) NOT NULL DEFAULT '',
"img2" character varying(500) NOT NULL DEFAULT '',
"img3" character varying(500) NOT NULL DEFAULT '',
"img4" character varying(500) NOT NULL DEFAULT '',
"img5" character varying(500) NOT NULL DEFAULT '',
"province_code" character varying(20) NOT NULL DEFAULT '',
"province" character varying(50) NOT NULL DEFAULT '',
"city_code" character varying(20) NOT NULL DEFAULT '',
"city" character varying(20) NOT NULL DEFAULT '',
"county_code" character varying(20) NOT NULL DEFAULT '',
"county" character varying(50) NOT NULL DEFAULT '',
"town_code" character varying(20) NOT NULL DEFAULT '',
"town" character varying(50) NOT NULL DEFAULT '',
"address" character varying(300) NOT NULL DEFAULT '',
"zipcode" character varying(50) NOT NULL DEFAULT '',
"phone" character varying(20) NOT NULL DEFAULT '',
"price" numeric(10,2) NOT NULL DEFAULT 0,
"view_amount" integer NOT NULL DEFAULT 0,
"amount" integer NOT NULL DEFAULT 0,
"is_closed" boolean NOT NULL DEFAULT false,
"post_ip" character varying(20) NOT NULL DEFAULT '',
"enabled" boolean NOT NULL DEFAULT true,
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "product" ADD CONSTRAINT "product_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "product" IS '产品';
COMMENT ON COLUMN "product"."identifier" IS '产品标识符';
COMMENT ON COLUMN "product"."company" IS '发布产品的企业：参考company表中的identifier字段';
COMMENT ON COLUMN "product"."member" IS '发布产品的会员：参考member表中的identifier字段';
COMMENT ON COLUMN "product"."category" IS '类目：参考product_category表中的identifier字段';
COMMENT ON COLUMN "product"."title" IS '标题';
COMMENT ON COLUMN "product"."brand" IS '产品品牌';
COMMENT ON COLUMN "product"."specification" IS '产品规格';
COMMENT ON COLUMN "product"."min_use_age" IS '最低适用年龄';
COMMENT ON COLUMN "product"."max_use_age" IS '最高适用年龄';
COMMENT ON COLUMN "product"."description" IS '详细描述';
COMMENT ON COLUMN "product"."image_server" IS '图片服务器地址';
COMMENT ON COLUMN "product"."cover" IS '封面图片';
COMMENT ON COLUMN "product"."img1" IS '第一张图片';
COMMENT ON COLUMN "product"."img2" IS '第二张图片';
COMMENT ON COLUMN "product"."img3" IS '第三张图片';
COMMENT ON COLUMN "product"."img4" IS '第四张图片';
COMMENT ON COLUMN "product"."img5" IS '第五张图片';
COMMENT ON COLUMN "product"."province_code" IS '产品发布的省份编码';
COMMENT ON COLUMN "product"."province" IS '产品发布的省份';
COMMENT ON COLUMN "product"."city_code" IS '产品发布的市编码';
COMMENT ON COLUMN "product"."city" IS '产品发布的市';
COMMENT ON COLUMN "product"."county_code" IS '产品发布的区或者县编码';
COMMENT ON COLUMN "product"."county" IS '产品发布的区或者县';
COMMENT ON COLUMN "product"."town_code" IS '产品发布的街道或者镇编码';
COMMENT ON COLUMN "product"."town" IS '产品发布的街道或者镇';
COMMENT ON COLUMN "product"."address" IS '产品发布的详细地址';
COMMENT ON COLUMN "product"."zipcode" IS '产品发布的邮政编码';
COMMENT ON COLUMN "product"."phone" IS '联系电话';
COMMENT ON COLUMN "product"."price" IS '交易价格';
COMMENT ON COLUMN "product"."view_amount" IS '浏览次数';
COMMENT ON COLUMN "product"."amount" IS '产品库存';
COMMENT ON COLUMN "product"."is_closed" IS '产品是否今天推荐：true-推荐、false-不推荐';
COMMENT ON COLUMN "product"."post_ip" IS '发布产品的ip';
COMMENT ON COLUMN "product"."enabled" IS '产品是否可用：true-可用、false-不可用';
COMMENT ON COLUMN "product"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "product"."gmt_modified" IS '最后修改时间戳';

DROP TABLE IF EXISTS "order"CASCADE;
CREATE TABLE "order" (
"identifier" character varying(50) NOT NULL,
"company" character varying(50) NOT NULL,
"family" character varying(50) NOT NULL,
"member" character varying(50) NOT NULL,
"nickname" character varying(50) NOT NULL DEFAULT '',
"title" character varying(50) NOT NULL,
"province_code" character varying(20) NOT NULL DEFAULT '',
"province" character varying(50) NOT NULL DEFAULT '',
"city_code" character varying(20) NOT NULL DEFAULT '',
"city" character varying(50) NOT NULL DEFAULT '',
"county_code" character varying(20) NOT NULL DEFAULT '',
"county" character varying(50) NOT NULL DEFAULT '',
"town_code" character varying(20) NOT NULL DEFAULT '',
"town" character varying(50) NOT NULL DEFAULT '',
"address" character varying(300) NOT NULL DEFAULT '',
"zipcode" character varying(50) NOT NULL DEFAULT '',
"addressee" character varying(50) NOT NULL DEFAULT '',
"phone" character varying(50) NOT NULL DEFAULT '',
"type" character varying(20) NOT NULL DEFAULT '',
"status" character varying(20) NOT NULL DEFAULT '',
"is_read" boolean NOT NULL DEFAULT false,
"remark" text NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "order" ADD CONSTRAINT "order_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "order" IS '订单表';
COMMENT ON COLUMN "order"."identifier" IS '订单标识符';
COMMENT ON COLUMN "order"."company" IS '向那家公司下的单：：参照company表中的identifier字段';
COMMENT ON COLUMN "order"."family" IS '下订单的家庭：参照family表中的identifier字段';
COMMENT ON COLUMN "order"."member" IS '下订单成员：参照member表中的identifier字段';
COMMENT ON COLUMN "order"."nickname" IS '下订单成员的名字：参照member表中的nickname字段';
COMMENT ON COLUMN "order"."title" IS '订单名称';
COMMENT ON COLUMN "order"."province_code" IS '订单配送地所在的省份编码';
COMMENT ON COLUMN "order"."province" IS '订单配送地所在的省份';
COMMENT ON COLUMN "order"."city_code" IS '订单配送地所在的市编码';
COMMENT ON COLUMN "order"."city" IS '订单配送地所在的市';
COMMENT ON COLUMN "order"."county_code" IS '订单配送地所在的区或者县编码';
COMMENT ON COLUMN "order"."county" IS '订单配送地所在的区或者县';
COMMENT ON COLUMN "order"."town_code" IS '订单配送地所在的街道或者镇编码';
COMMENT ON COLUMN "order"."town" IS '订单配送地所在的街道或者镇';
COMMENT ON COLUMN "order"."address" IS '订单配送地的详细地址';
COMMENT ON COLUMN "order"."zipcode" IS '订单配送地所在地的邮政编码';
COMMENT ON COLUMN "order"."addressee" IS '订单收件人';
COMMENT ON COLUMN "order"."phone" IS '订单联系电话';
COMMENT ON COLUMN "order"."type" IS '订单类型：01-现金兑奖、02-产品试用、03-支付购买、04-礼品卷、05-活动参与、06-红利会';
COMMENT ON COLUMN "order"."status" IS '订单状态，不同类型的订单，对应不同的订单状态：01-填写地址、02-等待发货、03-已发货、04-已完成、05-已取消、06-等待点评、07-填写电话、08-已预定、09-已参与、10-没参与';
COMMENT ON COLUMN "order"."is_read" IS '订单是否被阅读：false-未读、true-已读';
COMMENT ON COLUMN "order"."remark" IS '备注';
COMMENT ON COLUMN "order"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "order"."gmt_modified" IS '最后修改时间戳';

DROP TABLE IF EXISTS "order_product"CASCADE;
CREATE TABLE "order_product" (
"order" character varying(50) NOT NULL,
"product" character varying(50) NOT NULL,
"quantity" character varying(10) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "order_product" ADD CONSTRAINT "order_product_pk" PRIMARY KEY("order","product");
COMMENT ON TABLE "order_product" IS '订单产品关联表';
COMMENT ON COLUMN "order_product"."order" IS '订单标识符：参照order表中的identifier字段';
COMMENT ON COLUMN "order_product"."product" IS '产品标识符：参照product表中的identifier字段';
COMMENT ON COLUMN "order_product"."quantity" IS '产品数量';
COMMENT ON COLUMN "order_product"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "order_product"."gmt_modified" IS '最后修改时间戳';
-- 以上跟订单系统相关
*/


--一下跟邮件相关
DROP SEQUENCE IF EXISTS "mail_task_seq" CASCADE;
CREATE SEQUENCE mail_task_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER TABLE mail_task_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE mail_task_seq
  IS '用来生成mail_task表的标识符';

DROP TABLE IF EXISTS "mail_task"CASCADE;
CREATE TABLE "mail_task" (
"identifier" character varying(50) NOT NULL,
"smtp_server" character varying(50) NOT NULL DEFAULT '',
"username" character varying(50) NOT NULL DEFAULT '',
"password" character varying(50) NOT NULL DEFAULT '',
"subject" character varying(50) NOT NULL DEFAULT '',
"content" text NOT NULL DEFAULT '',
"filename" text NOT NULL DEFAULT '',
"send_ready_time" character varying(50) NOT NULL DEFAULT '',
"is_active" character varying(2) NOT NULL DEFAULT '01',
"number" integer NOT NULL DEFAULT 0,
"state" character varying(20) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "mail_task" ADD CONSTRAINT "mail_task_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "mail_task" IS '邮件任务表';
COMMENT ON COLUMN "mail_task"."identifier" IS '邮件标识符';
COMMENT ON COLUMN "mail_task"."smtp_server" IS '邮件服务器';
COMMENT ON COLUMN "mail_task"."username" IS '发件人';
COMMENT ON COLUMN "mail_task"."password" IS '密码';
COMMENT ON COLUMN "mail_task"."subject" IS '主题';
COMMENT ON COLUMN "mail_task"."content" IS '邮件内容';
COMMENT ON COLUMN "mail_task"."filename" IS '附件';
COMMENT ON COLUMN "mail_task"."send_ready_time" IS '群发时间';
COMMENT ON COLUMN "mail_task"."is_active" IS '是否需要邮箱激活 01-需要 02-不需要';
COMMENT ON COLUMN "mail_task"."number" IS '每小时发送邮件条数';
COMMENT ON COLUMN "mail_task"."state" IS '状态';
COMMENT ON COLUMN "mail_task"."gmt_modified" IS '最后修改时间戳';

--一下跟邮件相关
DROP SEQUENCE IF EXISTS "mail_task_log_seq" CASCADE;
CREATE SEQUENCE mail_task_log_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER TABLE mail_task_log_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE mail_task_log_seq
  IS '用来生成mail_task_log表的标识符';

DROP TABLE IF EXISTS "mail_task_log"CASCADE;
CREATE TABLE "mail_task_log" (
"identifier" character varying(50) NOT NULL,
"mail" character varying(50) NOT NULL DEFAULT '',
"nickname" character varying(50) NOT NULL DEFAULT '',
"email" character varying(100) NOT NULL DEFAULT '',
"send_ready_time" character varying(50) NOT NULL DEFAULT '',
"send_actual_time" character varying(50) NOT NULL DEFAULT '',
"state" character varying(20) NOT NULL DEFAULT '',
"remark" character varying(50) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "mail_task_log" ADD CONSTRAINT "mail_task_log_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "mail_task_log" IS '邮件任务记录表';
COMMENT ON COLUMN "mail_task_log"."identifier" IS '标识符';
COMMENT ON COLUMN "mail_task_log"."mail" IS '邮件标识符';
COMMENT ON COLUMN "mail_task_log"."nickname" IS '收件人';
COMMENT ON COLUMN "mail_task_log"."email" IS '收件邮箱';
COMMENT ON COLUMN "mail_task_log"."send_ready_time" IS '准备发送时间';
COMMENT ON COLUMN "mail_task_log"."send_actual_time" IS '实际发送时间';
COMMENT ON COLUMN "mail_task_log"."state" IS '状态';
COMMENT ON COLUMN "mail_task_log"."remark" IS '备注';
COMMENT ON COLUMN "mail_task_log"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "mail_task_log"."gmt_modified" IS '最后修改时间戳';
--以上跟邮件相关


DROP SEQUENCE IF EXISTS "album_seq" CASCADE;
CREATE SEQUENCE album_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER TABLE album_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE album_seq
  IS '用来生成album表的标识符';

DROP TABLE IF EXISTS "album" CASCADE;
CREATE TABLE "album" (
"identifier" character varying(50) NOT NULL,
"title" character varying(50) NOT NULL DEFAULT '',
"userid" character varying(50) NOT NULL DEFAULT '',
"username" character varying(50) NOT NULL DEFAULT '',
"usertype" character varying(2) NOT NULL DEFAULT '',
"album_type" character varying(2) NOT NULL DEFAULT '',
"description" character varying(500) NOT NULL DEFAULT '',
"views" integer NOT NULL DEFAULT 0,
"sort" integer NOT NULL DEFAULT 0,
"ip" character varying(20) NOT NULL DEFAULT '',
"display" character varying(2) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);

ALTER TABLE "album" ADD CONSTRAINT "album_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "album" IS '专辑';
COMMENT ON COLUMN "album"."identifier" IS '专辑标识';
COMMENT ON COLUMN "album"."title" IS '专辑的标题';
COMMENT ON COLUMN "album"."userid" IS '用户标识符';
COMMENT ON COLUMN "album"."username" IS '用户昵称';
COMMENT ON COLUMN "album"."usertype" IS '专辑的类型 01、后台人员 02、前台会员';
COMMENT ON COLUMN "album"."album_type" IS '专辑的类型 01、后台人员 02、前台会员';
COMMENT ON COLUMN "album"."description" IS '专辑描述';
COMMENT ON COLUMN "album"."views" IS '围观数';
COMMENT ON COLUMN "album"."sort" IS '序号';
COMMENT ON COLUMN "album"."ip" IS '发专辑的IP';
COMMENT ON COLUMN "album"."display" IS '专辑是否显示 01、需要 02、不需要';
COMMENT ON COLUMN "album"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "album"."gmt_modified" IS '最后修改时间戳';

DROP TABLE IF EXISTS "pictorial_doing" CASCADE;
CREATE TABLE "pictorial_doing" (
"pictorial" character varying(50) NOT NULL,
"doing" character varying(50) NOT NULL DEFAULT '',
"sort" integer NOT NULL DEFAULT 0,
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);

ALTER TABLE "pictorial_doing" ADD CONSTRAINT "pictorial_doing_pk" PRIMARY KEY("pictorial","doing");
COMMENT ON TABLE "pictorial_doing" IS 'pictorial和doing关联表';
COMMENT ON COLUMN "pictorial_doing"."pictorial" IS '画报标识';
COMMENT ON COLUMN "pictorial_doing"."doing" IS '微博标识';
COMMENT ON COLUMN "pictorial_doing"."sort" IS '序号';
COMMENT ON COLUMN "pictorial_doing"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "pictorial_doing"."gmt_modified" IS '最后修改时间戳';

--淘宝客报表
DROP SEQUENCE IF EXISTS "taobaoke_report_seq" CASCADE;
CREATE SEQUENCE taobaoke_report_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER SEQUENCE taobaoke_report_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE taobaoke_report_seq
  IS '用来生成taobaoke_report表的标识符';
DROP TABLE IF EXISTS "taobaoke_report" CASCADE;

CREATE TABLE "taobaoke_report" (
"identifier" character varying(50) NOT NULL DEFAULT nextval('taobaoke_report_seq'),
"trade_parent_id" character varying(50) NOt NULL DEFAULT '',
"trade_id" character varying(50) NOT NULL,
"real_pay_fee" numeric(12,2) NOT NULL DEFAULT '0.00',
"commission_rate" character varying(50) NOT NULL DEFAULT '',
"commission" numeric(12,2) NOT NULL DEFAULT '0.00',
"subsidy_rate" character varying(50) NOT NULL DEFAULT '',
"subsidy" numeric(12,2) NOT NULL DEFAULT '0.00',
"app_key" character varying(50) NOT NULL DEFAULT '',
"outer_code" character varying(50) NOT NULL DEFAULT '',
"create_time" date NULL,
"status" character varying(10) NOT NULL DEFAULT '',
"confirm_time" date NULL,
"pay_time" date NULL,
"pay_price" numeric(12,2) NOT NULL DEFAULT '0.00',
"num_iid" character varying(50) NOT NULL DEFAULT '',
"item_title" character varying(500) NOT NULL DEFAULT '',
"item_num" integer NOT NULL DEFAULT 0,
"category_id" character varying(50) NOT NULL DEFAULT '',
"category_name" character varying(500) NOT NULL DEFAULT '',
"shop_title" character varying(500) NOT NULL DEFAULT '',
"seller_nick" character varying(200) NOT NULL DEFAULT '',
"guoguojie_product_id" character varying(50) NOT NULL DEFAULT '',
"guoguojie_commission_rate" character varying(50) NOT NULL DEFAULT '',
"guoguojie_commission" numeric(12,2) NOT NULL DEFAULT '0.00',
"guoguojie_rebate" boolean NOT NULL DEFAULT false, 
"member" character varying(50) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);

ALTER TABLE "taobaoke_report" ADD CONSTRAINT "taobaoke_report_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "taobaoke_report" IS '淘宝客报表';
COMMENT ON COLUMN "taobaoke_report"."identifier" IS '标识符';
COMMENT ON COLUMN "taobaoke_report"."trade_parent_id" IS '淘宝父交易号';
COMMENT ON COLUMN "taobaoke_report"."trade_id" IS '淘宝交易号';
COMMENT ON COLUMN "taobaoke_report"."real_pay_fee" IS '实际支付金额';
COMMENT ON COLUMN "taobaoke_report"."commission_rate" IS '佣金比率。比如：0.01代表1%';
COMMENT ON COLUMN "taobaoke_report"."commission" IS '用户获得的佣金';
COMMENT ON COLUMN "taobaoke_report"."subsidy_rate" IS '补贴比率';
COMMENT ON COLUMN "taobaoke_report"."subsidy" IS '补贴金额';
COMMENT ON COLUMN "taobaoke_report"."app_key" IS '应用授权码';
COMMENT ON COLUMN "taobaoke_report"."outer_code" IS '推广渠道';
COMMENT ON COLUMN "taobaoke_report"."create_time" IS '订单创建时间';
COMMENT ON COLUMN "taobaoke_report"."status" IS '订单状态； N-新建 S-成功 F-失败';
COMMENT ON COLUMN "taobaoke_report"."confirm_time" IS '订单最终确认时间。 如果status为F，则代表订单失败时间； 如果status为S，则代表订单成功时间';
COMMENT ON COLUMN "taobaoke_report"."pay_time" IS '成交时间';
COMMENT ON COLUMN "taobaoke_report"."pay_price" IS '成交价格';
COMMENT ON COLUMN "taobaoke_report"."num_iid" IS '商品ID';
COMMENT ON COLUMN "taobaoke_report"."item_title" IS '商品标题';
COMMENT ON COLUMN "taobaoke_report"."item_num" IS '商品成交数量';
COMMENT ON COLUMN "taobaoke_report"."category_id" IS '所购买商品的类目ID';
COMMENT ON COLUMN "taobaoke_report"."category_name" IS '所购买商品的类目名称';
COMMENT ON COLUMN "taobaoke_report"."shop_title" IS '店铺名称';
COMMENT ON COLUMN "taobaoke_report"."seller_nick" IS '卖家昵称';
COMMENT ON COLUMN "taobaoke_report"."guoguojie_product_id" IS '果果街产品标识符: 参考doing_product表中的identifier字段';
COMMENT ON COLUMN "taobaoke_report"."guoguojie_commission_rate" IS '果果街佣金比率';
COMMENT ON COLUMN "taobaoke_report"."guoguojie_commission" IS '果果街佣金';
COMMENT ON COLUMN "taobaoke_report"."guoguojie_rebate" IS 'true-果果街已经给用户贴现,false-果果街未给用户贴现';
COMMENT ON COLUMN "taobaoke_report"."member" IS '会员，参考member表中的identifier字段';
COMMENT ON COLUMN "taobaoke_report"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "taobaoke_report"."gmt_modified" IS '最后修改时间戳';
CREATE UNIQUE INDEX "taobaoke_report_idx_trade_id" ON "taobaoke_report" USING btree ("trade_id");
--淘宝客报表


--话题
DROP SEQUENCE IF EXISTS "discuss_seq" CASCADE;
CREATE SEQUENCE discuss_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER SEQUENCE discuss_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE discuss_seq
  IS '用来生成discuss表的标识符';

DROP TABLE IF EXISTS "discuss"CASCADE;
CREATE TABLE "discuss" (
"identifier" character varying(50) NOT NULL,
"title" character varying(50) NOT NULL DEFAULT '',
"title_pic" character varying(500) NOT NULL DEFAULT '',
"creator" character varying(20) NOT NULL DEFAULT '',
"visit_amout" integer NOT NULL DEFAULT 0,
"reply_amout" integer NOT NULL DEFAULT 0,
"is_reply" boolean NOT NULL DEFAULT false,
"is_reply_pic" boolean NOT NULL DEFAULT false,
 "content" text NOT NULL DEFAULT '',
 "theme" character varying(50) NOT NULL DEFAULT '',
  "theme_id" character varying(50) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "discuss" ADD CONSTRAINT "discuss_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "discuss" IS '新帖子表';
COMMENT ON COLUMN "discuss"."identifier" IS '帖子标识符';
COMMENT ON COLUMN "discuss"."title" IS '帖子标题';
COMMENT ON COLUMN "discuss"."title_pic" IS '帖子标题图片';
COMMENT ON COLUMN "discuss"."creator" IS '发贴人';
COMMENT ON COLUMN "discuss"."visit_amout" IS '访问数量';
COMMENT ON COLUMN "discuss"."reply_amout" IS '回复数量';
COMMENT ON COLUMN "discuss"."is_reply" IS '是否可以回复';
COMMENT ON COLUMN "discuss"."is_reply_pic" IS '是否可以回复图片';
COMMENT ON COLUMN "discuss"."content" IS '内容';
COMMENT ON COLUMN "discuss"."theme" IS '主题类型，01-图片，02-商品，空-无主题'; 
COMMENT ON COLUMN "discuss"."theme_id" IS '主题标识'; 
COMMENT ON COLUMN "discuss"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "discuss"."gmt_modified" IS '最后修改时间戳';
--话题

--以下文稿标签
DROP SEQUENCE IF EXISTS "discuss_tag_seq" CASCADE;
CREATE SEQUENCE discuss_tag_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER SEQUENCE discuss_tag_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE discuss_tag_seq
  IS '用来生成discuss_tag表的标识符';

DROP TABLE IF EXISTS "discuss_tag" CASCADE;
CREATE TABLE "discuss_tag" (
"identifier" character varying(50) NOT NULL,
"name" character varying(200) NOT NULL DEFAULT '',
"channel" character varying(50) NOT NULL,
"enabled" boolean NOT NULL DEFAULT true,
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "discuss_tag" ADD CONSTRAINT "discuss_tag_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "discuss_tag" IS '文稿标签';
COMMENT ON COLUMN "discuss_tag"."identifier" IS '文稿标签标识符';
COMMENT ON COLUMN "discuss_tag"."name" IS '文稿标签的名称';
COMMENT ON COLUMN "discuss_tag"."channel" IS '文稿标签所属频道';
COMMENT ON COLUMN "discuss_tag"."enabled" IS '文稿标签是否可用';
COMMENT ON COLUMN "discuss_tag"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "discuss_tag"."gmt_modified" IS '最后修改时间戳';
--以上文稿标签

--以下文稿--标签关联表

DROP TABLE IF EXISTS "discuss_tag_dis"CASCADE;
CREATE TABLE "discuss_tag_dis" (
"discuss" character varying(50) NOT NULL,
"discuss_tag" character varying(50) NOT NULL,
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "discuss_tag_dis" ADD CONSTRAINT "discuss_tag_dis_pk" PRIMARY KEY("discuss","discuss_tag");
COMMENT ON TABLE "discuss_tag_dis" IS '文稿--标签关联表';
COMMENT ON COLUMN "discuss_tag_dis"."discuss" IS '文稿标识符：参照discuss表中的identifier字段';
COMMENT ON COLUMN "discuss_tag_dis"."discuss_tag" IS '文稿标签标识符：参照discuss_tag表中的identifier字段';
COMMENT ON COLUMN "discuss_tag_dis"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "discuss_tag_dis"."gmt_modified" IS '最后修改时间戳';
--以上文稿--标签关联表



--幸运排名
DROP SEQUENCE IF EXISTS "luck_time_seq" CASCADE;
CREATE SEQUENCE luck_time_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER SEQUENCE luck_time_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE luck_time_seq
  IS '用来生成luck_time表的标识符';

DROP TABLE IF EXISTS "luck_time" CASCADE;
CREATE TABLE "luck_time" (
"identifier" character varying(50) NOT NULL,
"title" character varying(50) NOT NULL DEFAULT '',
"ltime" character varying(50) NOT NULL DEFAULT '',
"description" character varying(500) NOT NULL DEFAULT '',
"status" character varying(10) NOT NULL DEFAULT 'ready',
"finanum" integer NOT NULL DEFAULT 0,
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "luck_time" ADD CONSTRAINT "luck_time_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "luck_time" IS '专辑';
COMMENT ON COLUMN "luck_time"."identifier" IS '幸运期标识';
COMMENT ON COLUMN "luck_time"."title" IS '标题';
COMMENT ON COLUMN "luck_time"."ltime" IS '时间';
COMMENT ON COLUMN "luck_time"."description" IS '描述';
COMMENT ON COLUMN "luck_time"."status" IS '状态 ready-准备,start-开始 end-结束';
COMMENT ON COLUMN "luck_time"."finanum" IS '入围数';
COMMENT ON COLUMN "luck_time"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "luck_time"."gmt_modified" IS '最后修改时间戳';
CREATE UNIQUE INDEX "luck_time_ltime" ON "luck_time" USING btree ("ltime");


DROP TABLE IF EXISTS "luck_rank" CASCADE;
CREATE TABLE "luck_rank" (
"luckid" character varying(50) NOT NULL,
"member" character varying(50) NOT NULL,
"luckdate" character varying(50) NOT NULL,
"ranknum" integer NOT NULL,
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "luck_rank" ADD CONSTRAINT "luck_rank_pk" PRIMARY KEY("luckid","member","ranknum");
COMMENT ON TABLE "luck_rank" IS '专辑';
COMMENT ON COLUMN "luck_rank"."luckid" IS '幸运期标识';
COMMENT ON COLUMN "luck_rank"."member" IS '会员标识';
COMMENT ON COLUMN "luck_rank"."luckdate" IS '抽奖时间';
COMMENT ON COLUMN "luck_rank"."ranknum" IS '幸运数字';
COMMENT ON COLUMN "luck_rank"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "luck_rank"."gmt_modified" IS '最后修改时间戳';
--幸运排名

--淘宝店铺
DROP SEQUENCE IF EXISTS "taobaoke_shop_seq" CASCADE;
CREATE SEQUENCE taobaoke_shop_seq
   INCREMENT 1
   START 100000000
   MINVALUE 100000000
   MAXVALUE 999999999;
ALTER SEQUENCE taobaoke_shop_seq OWNER TO guoguojie;
COMMENT ON SEQUENCE taobaoke_shop_seq
  IS '用来生成taobaoke_shop表的标识符';

DROP TABLE IF EXISTS "taobaoke_shop" CASCADE;
CREATE TABLE "taobaoke_shop" (
"identifier" character varying(50) NOT NULL,
"seller_id" character varying(50) NOT NULL DEFAULT '',
"shop_name" character varying(50) NOT NULL DEFAULT '',
"description" character varying(500) NOT NULL DEFAULT '',
"logo" character varying(500) NOT NULL DEFAULT '',
"website" character varying(200) NOT NULL DEFAULT '',
"gmt_created" timestamp with time zone NOT NULL DEFAULT now(),
"gmt_modified" timestamp with time zone NOT NULL DEFAULT now()
);
ALTER TABLE "taobaoke_shop" ADD CONSTRAINT "taobaoke_shop_pk" PRIMARY KEY("identifier");
COMMENT ON TABLE "taobaoke_shop" IS '淘宝店铺';
COMMENT ON COLUMN "taobaoke_shop"."identifier" IS '标识';
COMMENT ON COLUMN "taobaoke_shop"."seller_id" IS '卖家ID';
COMMENT ON COLUMN "taobaoke_shop"."shop_name" IS '名字';
COMMENT ON COLUMN "taobaoke_shop"."description" IS '描述';
COMMENT ON COLUMN "taobaoke_shop"."logo" IS '店铺logo图';
COMMENT ON COLUMN "taobaoke_shop"."website" IS '店铺地址';
COMMENT ON COLUMN "taobaoke_shop"."gmt_created" IS '创建时间戳';
COMMENT ON COLUMN "taobaoke_shop"."gmt_modified" IS '最后修改时间戳';
CREATE UNIQUE INDEX "taobaoke_shop_seller_id" ON "taobaoke_shop" USING btree ("seller_id");
--淘宝店铺

-- End 表's declaration
commit;
